Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmark cleanup #5177

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 14 additions & 11 deletions benchmark/assert/deepequal-prims-and-objs-big-array.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
'use strict';
var common = require('../common.js');
var assert = require('assert');

const primValues = {
'null': null,
'undefined': undefined,
'string': 'a',
'number': 1,
'boolean': true,
'object': { 0: 'a' },
'array': [1, 2, 3],
'new-array': new Array([1, 2, 3])
};

var bench = common.createBenchmark(main, {
prim: [
null,
undefined,
'a',
1,
true,
{0: 'a'},
[1, 2, 3],
new Array([1, 2, 3])
],
prim: Object.keys(primValues),
n: [25]
});

function main(conf) {
var prim = conf.prim;
var prim = primValues[conf.prim];
var n = +conf.n;
var primArray;
var primArrayCompare;
Expand Down
25 changes: 14 additions & 11 deletions benchmark/assert/deepequal-prims-and-objs-big-loop.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
'use strict';
var common = require('../common.js');
var assert = require('assert');

const primValues = {
'null': null,
'undefined': undefined,
'string': 'a',
'number': 1,
'boolean': true,
'object': { 0: 'a' },
'array': [1, 2, 3],
'new-array': new Array([1, 2, 3])
};

var bench = common.createBenchmark(main, {
prim: [
null,
undefined,
'a',
1,
true,
{0: 'a'},
[1, 2, 3],
new Array([1, 2, 3])
],
prim: Object.keys(primValues),
n: [1e5]
});

function main(conf) {
var prim = conf.prim;
var prim = primValues[conf.prim];
var n = +conf.n;
var x;

Expand Down
2 changes: 1 addition & 1 deletion benchmark/buffers/buffer-read.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
var common = require('../common.js');

var bench = common.createBenchmark(main, {
noAssert: [false, true],
noAssert: ['false', 'true'],
buffer: ['fast', 'slow'],
type: ['UInt8', 'UInt16LE', 'UInt16BE',
'UInt32LE', 'UInt32BE',
Expand Down
4 changes: 2 additions & 2 deletions benchmark/buffers/buffer-tostring.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
const common = require('../common.js');

const bench = common.createBenchmark(main, {
arg: [true, false],
arg: ['true', 'false'],
len: [0, 1, 64, 1024],
n: [1e7]
});

function main(conf) {
const arg = conf.arg;
const arg = conf.arg === 'true';
const len = conf.len | 0;
const n = conf.n | 0;
const buf = Buffer(len).fill(42);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/buffers/buffer-write.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
var common = require('../common.js');
var bench = common.createBenchmark(main, {
noAssert: [false, true],
noAssert: ['false', 'true'],
buffer: ['fast', 'slow'],
type: ['UInt8', 'UInt16LE', 'UInt16BE',
'UInt32LE', 'UInt32BE',
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions benchmark/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ Benchmark.prototype._run = function() {
var j = 0;
set.forEach(function(s) {
vals.forEach(function(val) {
if (typeof val !== 'number' && typeof val !== 'string') {
throw new TypeError(`configuration "${key}" had type ${typeof val}`);
}

newSet[j++] = s.concat(key + '=' + val);
});
});
Expand Down
File renamed without changes.
41 changes: 0 additions & 41 deletions benchmark/misc/url.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 25 additions & 12 deletions benchmark/url/url-resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,43 @@ var common = require('../common.js');
var url = require('url');
var v8 = require('v8');

var hrefs = [
'http://example.com/',
'http://nodejs.org/docs/latest/api/url.html#url_url_format_urlobj',
'http://blog.nodejs.org/',
'https://encrypted.google.com/search?q=url&q=site:npmjs.org&hl=en',
'javascript:alert("node is awesome");',
'some.ran/dom/url.thing?oh=yes#whoo'
];


var paths = [
'../../../../../etc/passwd',
'../foo/bar?baz=boom',
'foo/bar',
'http://nodejs.org',
'./foo/bar?baz'
];

var bench = common.createBenchmark(main, {
type: ['one'],
n: [1e5],
href: Object.keys(hrefs),
path: Object.keys(paths),
n: [1e5]
});

function main(conf) {
var type = conf.type;
var n = conf.n | 0;

var inputs = {
one: ['http://example.com/', '../../../../../etc/passwd'],
};
var input = inputs[type] || [];
var href = hrefs[conf.href];
var path = paths[conf.path];

// Force-optimize url.resolve() so that the benchmark doesn't get
// disrupted by the optimizer kicking in halfway through.
for (var name in inputs)
url.resolve(inputs[name][0], inputs[name][1]);

url.resolve(href, path);
v8.setFlagsFromString('--allow_natives_syntax');
eval('%OptimizeFunctionOnNextCall(url.resolve)');

bench.start();
for (var i = 0; i < n; i += 1)
url.resolve(input[0], input[1]);
url.resolve(href, path);
bench.end(n);
}