tinybench icon indicating copy to clipboard operation
tinybench copied to clipboard

Error while Benchmark Execution

Open dkbhadeshiya opened this issue 2 years ago • 3 comments

Hi,

I have been trying to run a benchmark on crypto.randomUUID vs uuid.v4() function.

I hit the following error:

[redacted]/test-bench/node_modules/tinybench/dist/index.cjs:386
      "ops/sec": parseInt(e.hz.toString(), 10).toLocaleString(),
                               ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at [redacted]/test-bench/node_modules/tinybench/dist/index.cjs:386:32
    at Array.map (<anonymous>)
    at u.table ([redacted]/test-bench/node_modules/tinybench/dist/index.cjs:384:23)
    at [redacted]/test-bench/uuid.js:11:25

Node.js v21.5.0

Here is my sample script which I am using to do the testing:

const { Bench } = require('tinybench');
const { v4 } = require('uuid');

const bench = new Bench({ time: 10000 });

bench
  .add('Generate ID', () => {
    v4();
  });
bench.run().then(() => {
    console.table(bench.table());
})

dkbhadeshiya avatar Jan 15 '24 11:01 dkbhadeshiya

Same behaviour happened while using crypto.randomUUID() function.

[redacted]/test-bench/node_modules/tinybench/dist/index.cjs:386
      "ops/sec": parseInt(e.hz.toString(), 10).toLocaleString(),
                               ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at [redacted]/test-bench/node_modules/tinybench/dist/index.cjs:386:32
    at Array.map (<anonymous>)
    at u.table ([redacted]/test-bench/node_modules/tinybench/dist/index.cjs:384:23)
    at [redacted]/test-bench/crypt-uuid.js:11:25

Node.js v21.5.0

Script for testing crypto.randomUUID()

const { Bench } = require('tinybench');
const { randomUUID } = require('crypto');

const bench = new Bench({ time: 10000 });

bench
  .add('Generate ID', () => {
    randomUUID();
  });
bench.run().then(() => {
    console.table(bench.table());
})

dkbhadeshiya avatar Jan 15 '24 11:01 dkbhadeshiya

Looks like this should be fixed by now https://github.com/tinylibs/tinybench/commit/ab950e03ccac536b4d382433f6dc410ad3360933#diff-c19b4a9aa70c935caded8b62cdaf76680cf0034fdc146a383a60ed2607c854c9R164-R167

@Aslemammad, could you release a new version?

sirenkovladd avatar Jan 15 '24 21:01 sirenkovladd

Looks like this should be fixed by now https://github.com/tinylibs/tinybench/commit/ab950e03ccac536b4d382433f6dc410ad3360933#diff-c19b4a9aa70c935caded8b62cdaf76680cf0034fdc146a383a60ed2607c854c9R164-R167

@Aslemammad, could you release a new version?

Thank you so much, do you want to be a member of tinylibs?

Aslemammad avatar Jan 15 '24 21:01 Aslemammad