From: Jérôme Benoit Date: Mon, 24 Oct 2022 19:49:10 +0000 (+0200) Subject: Switch all benchmarks to benny X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=662a730a20d42b0057cf65d1baeb77982e29d3ba;p=benchmarks-js.git Switch all benchmarks to benny Signed-off-by: Jérôme Benoit --- diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..879d126 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +benchmark/results/ \ No newline at end of file diff --git a/busy-wait.js b/busy-wait.js index eece669..9d0d31b 100644 --- a/busy-wait.js +++ b/busy-wait.js @@ -1,7 +1,5 @@ -const Benchmark = require('benchmark') -const { LIST_FORMATTER, sleep } = require('./benchmark-utils') - -const suite = new Benchmark.Suite() +const Benchmark = require('benny') +const { sleep } = require('./benchmark-utils') const timeout = 2000 const interval = 1000 @@ -56,27 +54,23 @@ function setIntervalTimeoutBusyWait (timeoutMs, intervalMs = interval) { }, intervalMs) } -suite - .add('dummyTimeoutBusyWait', () => { +Benchmark.suite( + 'Busy wait', + Benchmark.add('dummyTimeoutBusyWait', () => { dummyTimeoutBusyWait(timeout) - }) - .add('sleepTimeoutBusyWait', async () => { + }), + Benchmark.add('sleepTimeoutBusyWait', async () => { await sleepTimeoutBusyWait(timeout) - }) - .add('divideAndConquerTimeoutBusyWait', async () => { + }), + Benchmark.add('divideAndConquerTimeoutBusyWait', async () => { await divideAndConquerTimeoutBusyWait(timeout) - }) - .add('setIntervalTimeoutBusyWait', () => { + }), + Benchmark.add('setIntervalTimeoutBusyWait', () => { setIntervalTimeoutBusyWait(timeout) - }) - .on('cycle', event => { - console.log(event.target.toString()) - }) - .on('complete', function () { - console.log( - 'Fastest is ' + LIST_FORMATTER.format(this.filter('fastest').map('name')) - ) - // eslint-disable-next-line n/no-process-exit - process.exit() - }) - .run() + }), + Benchmark.cycle(), + Benchmark.complete(), + Benchmark.save({ file: 'busy-wait', format: 'json', details: true }), + Benchmark.save({ file: 'busy-wait', format: 'chart.html', details: true }), + Benchmark.save({ file: 'busy-wait', format: 'table.html', details: true }) +) diff --git a/fibonacci.js b/fibonacci.js index 729fe92..edde903 100644 --- a/fibonacci.js +++ b/fibonacci.js @@ -1,7 +1,4 @@ -const Benchmark = require('benchmark') -const { LIST_FORMATTER } = require('./benchmark-utils') - -const suite = new Benchmark.Suite() +const Benchmark = require('benny') const number = 30 @@ -50,24 +47,20 @@ function fibonacciRecursionMemoization (num, memo) { fibonacciRecursionMemoization(num - 2, memo)) } -suite - .add('fibonacciLoop', () => { +Benchmark.suite( + 'Fibonacci', + Benchmark.add('fibonacciLoop', () => { fibonacciLoop(number) - }) - .add('fibonacciRecursion', () => { + }), + Benchmark.add('fibonacciRecursion', () => { fibonacciRecursion(number) - }) - .add('fibonacciRecursionMemoization', () => { + }), + Benchmark.add('fibonacciRecursionMemoization', () => { fibonacciRecursionMemoization(number) - }) - .on('cycle', event => { - console.log(event.target.toString()) - }) - .on('complete', function () { - console.log( - 'Fastest is ' + LIST_FORMATTER.format(this.filter('fastest').map('name')) - ) - // eslint-disable-next-line n/no-process-exit - process.exit() - }) - .run() + }), + Benchmark.cycle(), + Benchmark.complete(), + Benchmark.save({ file: 'fibonacci', format: 'json', details: true }), + Benchmark.save({ file: 'fibonacci', format: 'chart.html', details: true }), + Benchmark.save({ file: 'fibonacci', format: 'table.html', details: true }) +) diff --git a/package-lock.json b/package-lock.json index 01c510d..e230b34 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,6 @@ "version": "0.0.1", "license": "MIT", "dependencies": { - "benchmark": "^2.1.4", "benny": "^3.7.1", "microtime": "^3.1.1", "uuid": "^9.0.0", diff --git a/package.json b/package.json index ba94b0c..801e41e 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,6 @@ "author": "jerome-benoit", "license": "MIT", "dependencies": { - "benchmark": "^2.1.4", "benny": "^3.7.1", "microtime": "^3.1.1", "uuid": "^9.0.0",