Skip to content

Commit

Permalink
Rework benchmark to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasBuelens committed Jan 5, 2025
1 parent ca86f00 commit 295f89c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 10 deletions.
13 changes: 6 additions & 7 deletions test/benchmark/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const Benchmark = require('benchmark');
const polyfill = require('../../dist/ponyfill.js');
const stardazed = require('@stardazed/streams');
import Benchmark from 'benchmark';
import * as polyfill from 'web-streams-polyfill';
import * as stardazed from '@stardazed/streams';

const suite = new Benchmark.Suite();

const implementations = [
Expand All @@ -24,7 +25,7 @@ function testCount(impl, count, deferred) {
}

function readLoop(count, reader) {
return reader.read().then(result => {
return reader.read().then((result) => {
if (result.done) {
return undefined;
}
Expand All @@ -43,13 +44,11 @@ for (const [name, impl] of implementations) {
}

suite
.on('cycle', event => {
// eslint-disable-next-line no-console
.on('cycle', (event) => {
const bench = event.target;
console.log(`${String(bench)} (period: ${(bench.times.period * 1000).toFixed(2)}ms)`);
})
.on('complete', () => {
// eslint-disable-next-line no-console
console.log('Done');
})
.run({ async: true });
38 changes: 37 additions & 1 deletion test/benchmark/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions test/benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"name": "web-streams-polyfill-benchmark",
"version": "0.0.0",
"private": true,
"main": "index.js",
"type": "module",
"scripts": {
"benchmark": "node --prof index.js"
},
"devDependencies": {
"@stardazed/streams": "^3.1.0",
"benchmark": "^2.1.4"
"benchmark": "^2.1.4",
"web-streams-polyfill": "file:../.."
}
}

0 comments on commit 295f89c

Please sign in to comment.