Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
tools, benchmark: test util benchmark
  • Loading branch information
sarahmeyer authored and Trott committed Oct 27, 2017
commit 88c786dab6f21c46c14eba2033d5174a1f0754db
4 changes: 2 additions & 2 deletions benchmark/util/type-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const bench = common.createBenchmark(main, {
type: Object.keys(args),
version: ['native', 'js'],
argument: ['true', 'false-primitive', 'false-object'],
millions: ['5']
n: [1e7]
}, {
flags: ['--expose-internals']
});
Expand All @@ -38,7 +38,7 @@ function main(conf) {
const util = process.binding('util');
const types = require('internal/util/types');

const n = (+conf.millions * 1e6) | 0;
const n = (+conf.n * 1e6) | 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would increase n from 5 * 1e6 to 1e7 * 1e6, which is going to cost more time if the benchmark is run normally. Can you change the default n to 5e6 and use that value as-is(without multiplying) instead?

Copy link
Copy Markdown
Contributor

@Fishrock123 Fishrock123 Oct 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, I agree that is a better solution. (Please keep the number coercion bits though.)

const func = { native: util, js: types }[conf.version][`is${conf.type}`];
const arg = args[conf.type][conf.argument];

Expand Down
7 changes: 7 additions & 0 deletions test/parallel/test-benchmark-util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

require('../common');

const runBenchmark = require('../common/benchmark');

runBenchmark('util', ['n=1', 'arguments=0']);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting arguments=0 would turn the arg in the test undefined. I believe we are good with n=1 only.