summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/buffers/buffer-compare-instance-method.js25
-rw-r--r--benchmark/buffers/buffer-compare-offset.js9
-rw-r--r--benchmark/buffers/buffer-compare.js9
-rw-r--r--benchmark/buffers/buffer-read-float.js8
-rw-r--r--benchmark/buffers/buffer-read-with-byteLength.js8
-rw-r--r--benchmark/buffers/buffer-read.js9
-rw-r--r--benchmark/buffers/buffer-write.js28
-rw-r--r--benchmark/buffers/dataview-set.js13
-rw-r--r--benchmark/es/defaultparams-bench.js20
-rw-r--r--benchmark/es/destructuring-bench.js20
-rw-r--r--benchmark/es/destructuring-object-bench.js20
-rw-r--r--benchmark/es/foreach-bench.js30
-rw-r--r--benchmark/es/map-bench.js52
-rw-r--r--benchmark/es/restparams-bench.js20
-rw-r--r--benchmark/es/spread-assign.js5
-rw-r--r--benchmark/es/spread-bench.js16
-rw-r--r--benchmark/misc/function_call/index.js10
-rw-r--r--benchmark/misc/object-property-bench.js13
-rw-r--r--benchmark/module/module-loader.js27
-rw-r--r--benchmark/process/next-tick-breadth-args.js33
-rw-r--r--benchmark/process/next-tick-breadth.js15
-rw-r--r--benchmark/process/next-tick-depth-args.js14
-rw-r--r--benchmark/process/next-tick-depth.js7
-rw-r--r--benchmark/process/next-tick-exec-args.js7
-rw-r--r--benchmark/process/next-tick-exec.js7
-rw-r--r--benchmark/streams/readable-bigread.js2
-rw-r--r--benchmark/streams/readable-bigunevenread.js2
-rw-r--r--benchmark/streams/readable-unevenread.js2
-rw-r--r--benchmark/timers/immediate.js29
-rw-r--r--benchmark/timers/set-immediate-breadth-args.js9
-rw-r--r--benchmark/timers/set-immediate-breadth.js9
-rw-r--r--benchmark/timers/set-immediate-depth-args.js9
-rw-r--r--benchmark/timers/timers-breadth.js15
-rw-r--r--benchmark/timers/timers-cancel-pooled.js11
-rw-r--r--benchmark/timers/timers-cancel-unpooled.js11
-rw-r--r--benchmark/timers/timers-depth.js13
-rw-r--r--benchmark/timers/timers-insert-pooled.js9
-rw-r--r--benchmark/timers/timers-insert-unpooled.js12
-rw-r--r--benchmark/timers/timers-timeout-pooled.js15
39 files changed, 274 insertions, 299 deletions
diff --git a/benchmark/buffers/buffer-compare-instance-method.js b/benchmark/buffers/buffer-compare-instance-method.js
index a3433803b7..77a3e84fa7 100644
--- a/benchmark/buffers/buffer-compare-instance-method.js
+++ b/benchmark/buffers/buffer-compare-instance-method.js
@@ -4,11 +4,10 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, {
size: [16, 512, 1024, 4096, 16386],
args: [1, 2, 3, 4, 5],
- millions: [1]
+ n: [1e6]
});
-function main({ millions, size, args }) {
- const iter = millions * 1e6;
+function main({ n, size, args }) {
const b0 = Buffer.alloc(size, 'a');
const b1 = Buffer.alloc(size, 'a');
const b0Len = b0.length;
@@ -37,41 +36,41 @@ function main({ millions, size, args }) {
case 2:
b0.compare(b1, 0);
bench.start();
- for (i = 0; i < iter; i++) {
+ for (i = 0; i < n; i++) {
b0.compare(b1, 0);
}
- bench.end(iter / 1e6);
+ bench.end(n);
break;
case 3:
b0.compare(b1, 0, b1Len);
bench.start();
- for (i = 0; i < iter; i++) {
+ for (i = 0; i < n; i++) {
b0.compare(b1, 0, b1Len);
}
- bench.end(iter / 1e6);
+ bench.end(n);
break;
case 4:
b0.compare(b1, 0, b1Len, 0);
bench.start();
- for (i = 0; i < iter; i++) {
+ for (i = 0; i < n; i++) {
b0.compare(b1, 0, b1Len, 0);
}
- bench.end(iter / 1e6);
+ bench.end(n);
break;
case 5:
b0.compare(b1, 0, b1Len, 0, b0Len);
bench.start();
- for (i = 0; i < iter; i++) {
+ for (i = 0; i < n; i++) {
b0.compare(b1, 0, b1Len, 0, b0Len);
}
- bench.end(iter / 1e6);
+ bench.end(n);
break;
default:
b0.compare(b1);
bench.start();
- for (i = 0; i < iter; i++) {
+ for (i = 0; i < n; i++) {
b0.compare(b1);
}
- bench.end(iter / 1e6);
+ bench.end(n);
}
}
diff --git a/benchmark/buffers/buffer-compare-offset.js b/benchmark/buffers/buffer-compare-offset.js
index 551fcd2f0c..89cc4427d9 100644
--- a/benchmark/buffers/buffer-compare-offset.js
+++ b/benchmark/buffers/buffer-compare-offset.js
@@ -4,7 +4,7 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, {
method: ['offset', 'slice'],
size: [16, 512, 1024, 4096, 16386],
- millions: [1]
+ n: [1e6]
});
function compareUsingSlice(b0, b1, len, iter) {
@@ -17,13 +17,12 @@ function compareUsingOffset(b0, b1, len, iter) {
b0.compare(b1, 1, len, 1, len);
}
-function main({ millions, size, method }) {
- const iter = millions * 1e6;
+function main({ n, size, method }) {
const fn = method === 'slice' ? compareUsingSlice : compareUsingOffset;
bench.start();
fn(Buffer.alloc(size, 'a'),
Buffer.alloc(size, 'b'),
size >> 1,
- iter);
- bench.end(millions);
+ n);
+ bench.end(n);
}
diff --git a/benchmark/buffers/buffer-compare.js b/benchmark/buffers/buffer-compare.js
index f7abb4b3d9..cb4f0f475c 100644
--- a/benchmark/buffers/buffer-compare.js
+++ b/benchmark/buffers/buffer-compare.js
@@ -24,19 +24,18 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, {
size: [16, 512, 1024, 4096, 16386],
- millions: [1]
+ n: [1e6]
});
-function main({ millions, size }) {
- const iter = millions * 1e6;
+function main({ n, size }) {
const b0 = Buffer.alloc(size, 'a');
const b1 = Buffer.alloc(size, 'a');
b1[size - 1] = 'b'.charCodeAt(0);
bench.start();
- for (var i = 0; i < iter; i++) {
+ for (var i = 0; i < n; i++) {
Buffer.compare(b0, b1);
}
- bench.end(iter / 1e6);
+ bench.end(n);
}
diff --git a/benchmark/buffers/buffer-read-float.js b/benchmark/buffers/buffer-read-float.js
index e105642972..dbccf57393 100644
--- a/benchmark/buffers/buffer-read-float.js
+++ b/benchmark/buffers/buffer-read-float.js
@@ -5,10 +5,10 @@ const bench = common.createBenchmark(main, {
type: ['Double', 'Float'],
endian: ['BE', 'LE'],
value: ['zero', 'big', 'small', 'inf', 'nan'],
- millions: [1]
+ n: [1e6]
});
-function main({ millions, type, endian, value }) {
+function main({ n, type, endian, value }) {
type = type || 'Double';
const buff = Buffer.alloc(8);
const fn = `read${type}${endian}`;
@@ -32,8 +32,8 @@ function main({ millions, type, endian, value }) {
buff[`write${type}${endian}`](values[type][value], 0);
bench.start();
- for (var i = 0; i !== millions * 1e6; i++) {
+ for (var i = 0; i !== n; i++) {
buff[fn](0);
}
- bench.end(millions);
+ bench.end(n);
}
diff --git a/benchmark/buffers/buffer-read-with-byteLength.js b/benchmark/buffers/buffer-read-with-byteLength.js
index 1858c4fd96..93deab2ab0 100644
--- a/benchmark/buffers/buffer-read-with-byteLength.js
+++ b/benchmark/buffers/buffer-read-with-byteLength.js
@@ -11,19 +11,19 @@ const types = [
const bench = common.createBenchmark(main, {
buffer: ['fast', 'slow'],
type: types,
- millions: [1],
+ n: [1e6],
byteLength: [1, 2, 3, 4, 5, 6]
});
-function main({ millions, buf, type, byteLength }) {
+function main({ n, buf, type, byteLength }) {
const clazz = buf === 'fast' ? Buffer : require('buffer').SlowBuffer;
const buff = new clazz(8);
const fn = `read${type || 'IntBE'}`;
buff.writeDoubleLE(0, 0);
bench.start();
- for (var i = 0; i !== millions * 1e6; i++) {
+ for (var i = 0; i !== n; i++) {
buff[fn](0, byteLength);
}
- bench.end(millions);
+ bench.end(n);
}
diff --git a/benchmark/buffers/buffer-read.js b/benchmark/buffers/buffer-read.js
index 88a46cb290..eccbdc507d 100644
--- a/benchmark/buffers/buffer-read.js
+++ b/benchmark/buffers/buffer-read.js
@@ -21,18 +21,19 @@ const types = [
const bench = common.createBenchmark(main, {
buffer: ['fast', 'slow'],
type: types,
- millions: [1]
+ n: [1e6]
});
-function main({ millions, buf, type }) {
+function main({ n, buf, type }) {
const clazz = buf === 'fast' ? Buffer : require('buffer').SlowBuffer;
const buff = new clazz(8);
const fn = `read${type || 'UInt8'}`;
buff.writeDoubleLE(0, 0);
bench.start();
- for (var i = 0; i !== millions * 1e6; i++) {
+
+ for (var i = 0; i !== n; i++) {
buff[fn](0);
}
- bench.end(millions);
+ bench.end(n);
}
diff --git a/benchmark/buffers/buffer-write.js b/benchmark/buffers/buffer-write.js
index 297059c192..556423a15c 100644
--- a/benchmark/buffers/buffer-write.js
+++ b/benchmark/buffers/buffer-write.js
@@ -25,7 +25,7 @@ const types = [
const bench = common.createBenchmark(main, {
buffer: ['fast', 'slow'],
type: types,
- millions: [1]
+ n: [1e6]
});
const INT8 = 0x7f;
@@ -60,42 +60,42 @@ const byteLength = {
writeIntBE: 6
};
-function main({ millions, buf, type }) {
+function main({ n, buf, type }) {
const clazz = buf === 'fast' ? Buffer : require('buffer').SlowBuffer;
const buff = new clazz(8);
const fn = `write${type || 'UInt8'}`;
if (!/\d/.test(fn))
- benchSpecialInt(buff, fn, millions);
+ benchSpecialInt(buff, fn, n);
else if (/Int/.test(fn))
- benchInt(buff, fn, millions);
+ benchInt(buff, fn, n);
else
- benchFloat(buff, fn, millions);
+ benchFloat(buff, fn, n);
}
-function benchInt(buff, fn, millions) {
+function benchInt(buff, fn, n) {
const m = mod[fn];
bench.start();
- for (var i = 0; i !== millions * 1e6; i++) {
+ for (var i = 0; i !== n; i++) {
buff[fn](i & m, 0);
}
- bench.end(millions);
+ bench.end(n);
}
-function benchSpecialInt(buff, fn, millions) {
+function benchSpecialInt(buff, fn, n) {
const m = mod[fn];
const byte = byteLength[fn];
bench.start();
- for (var i = 0; i !== millions * 1e6; i++) {
+ for (var i = 0; i !== n; i++) {
buff[fn](i & m, 0, byte);
}
- bench.end(millions);
+ bench.end(n);
}
-function benchFloat(buff, fn, millions) {
+function benchFloat(buff, fn, n) {
bench.start();
- for (var i = 0; i !== millions * 1e6; i++) {
+ for (var i = 0; i !== n; i++) {
buff[fn](i, 0);
}
- bench.end(millions);
+ bench.end(n);
}
diff --git a/benchmark/buffers/dataview-set.js b/benchmark/buffers/dataview-set.js
index ee5acfb1c1..00a7114bdd 100644
--- a/benchmark/buffers/dataview-set.js
+++ b/benchmark/buffers/dataview-set.js
@@ -20,7 +20,7 @@ const types = [
const bench = common.createBenchmark(main, {
type: types,
- millions: [1]
+ n: [1e6]
});
const INT8 = 0x7f;
@@ -39,18 +39,17 @@ const mod = {
setUint32: UINT32
};
-function main({ millions, type }) {
+function main({ n, type }) {
type = type || 'Uint8';
- const len = millions * 1e6;
const ab = new ArrayBuffer(8);
const dv = new DataView(ab, 0, 8);
const le = /LE$/.test(type);
const fn = `set${type.replace(/[LB]E$/, '')}`;
if (/int/i.test(fn))
- benchInt(dv, fn, len, le);
+ benchInt(dv, fn, n, le);
else
- benchFloat(dv, fn, len, le);
+ benchFloat(dv, fn, n, le);
}
function benchInt(dv, fn, len, le) {
@@ -60,7 +59,7 @@ function benchInt(dv, fn, len, le) {
for (var i = 0; i < len; i++) {
method.call(dv, 0, i % m, le);
}
- bench.end(len / 1e6);
+ bench.end(len);
}
function benchFloat(dv, fn, len, le) {
@@ -69,5 +68,5 @@ function benchFloat(dv, fn, len, le) {
for (var i = 0; i < len; i++) {
method.call(dv, 0, i * 0.1, le);
}
- bench.end(len / 1e6);
+ bench.end(len);
}
diff --git a/benchmark/es/defaultparams-bench.js b/benchmark/es/defaultparams-bench.js
index a00b50137c..c568c12ae0 100644
--- a/benchmark/es/defaultparams-bench.js
+++ b/benchmark/es/defaultparams-bench.js
@@ -5,7 +5,7 @@ const assert = require('assert');
const bench = common.createBenchmark(main, {
method: ['withoutdefaults', 'withdefaults'],
- millions: [100]
+ n: [1e8]
});
function oldStyleDefaults(x, y) {
@@ -20,29 +20,29 @@ function defaultParams(x = 1, y = 2) {
assert.strictEqual(y, 2);
}
-function runOldStyleDefaults(millions) {
+function runOldStyleDefaults(n) {
bench.start();
- for (var i = 0; i < millions * 1e6; i++)
+ for (var i = 0; i < n; i++)
oldStyleDefaults();
- bench.end(millions);
+ bench.end(n);
}
-function runDefaultParams(millions) {
+function runDefaultParams(n) {
bench.start();
- for (var i = 0; i < millions * 1e6; i++)
+ for (var i = 0; i < n; i++)
defaultParams();
- bench.end(millions);
+ bench.end(n);
}
-function main({ millions, method }) {
+function main({ n, method }) {
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'withoutdefaults':
- runOldStyleDefaults(millions);
+ runOldStyleDefaults(n);
break;
case 'withdefaults':
- runDefaultParams(millions);
+ runDefaultParams(n);
break;
default:
throw new Error(`Unexpected method "${method}"`);
diff --git a/benchmark/es/destructuring-bench.js b/benchmark/es/destructuring-bench.js
index 2168940bdc..37f3fd9ad3 100644
--- a/benchmark/es/destructuring-bench.js
+++ b/benchmark/es/destructuring-bench.js
@@ -5,13 +5,13 @@ const assert = require('assert');
const bench = common.createBenchmark(main, {
method: ['swap', 'destructure'],
- millions: [100]
+ n: [1e8]
});
-function runSwapManual(millions) {
+function runSwapManual(n) {
var x, y, r;
bench.start();
- for (var i = 0; i < millions * 1e6; i++) {
+ for (var i = 0; i < n; i++) {
x = 1, y = 2;
r = x;
x = y;
@@ -19,30 +19,30 @@ function runSwapManual(millions) {
assert.strictEqual(x, 2);
assert.strictEqual(y, 1);
}
- bench.end(millions);
+ bench.end(n);
}
-function runSwapDestructured(millions) {
+function runSwapDestructured(n) {
var x, y;
bench.start();
- for (var i = 0; i < millions * 1e6; i++) {
+ for (var i = 0; i < n; i++) {
x = 1, y = 2;
[x, y] = [y, x];
assert.strictEqual(x, 2);
assert.strictEqual(y, 1);
}
- bench.end(millions);
+ bench.end(n);
}
-function main({ millions, method }) {
+function main({ n, method }) {
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'swap':
- runSwapManual(millions);
+ runSwapManual(n);
break;
case 'destructure':
- runSwapDestructured(millions);
+ runSwapDestructured(n);
break;
default:
throw new Error(`Unexpected method "${method}"`);
diff --git a/benchmark/es/destructuring-object-bench.js b/benchmark/es/destructuring-object-bench.js
index a84977c59b..0c5615fd1e 100644
--- a/benchmark/es/destructuring-object-bench.js
+++ b/benchmark/es/destructuring-object-bench.js
@@ -4,44 +4,44 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, {
method: ['normal', 'destructureObject'],
- millions: [100]
+ n: [1e8]
});
-function runNormal(millions) {
+function runNormal(n) {
var i = 0;
const o = { x: 0, y: 1 };
bench.start();
- for (; i < millions * 1e6; i++) {
+ for (; i < n; i++) {
/* eslint-disable no-unused-vars */
const x = o.x;
const y = o.y;
const r = o.r || 2;
/* eslint-enable no-unused-vars */
}
- bench.end(millions);
+ bench.end(n);
}
-function runDestructured(millions) {
+function runDestructured(n) {
var i = 0;
const o = { x: 0, y: 1 };
bench.start();
- for (; i < millions * 1e6; i++) {
+ for (; i < n; i++) {
/* eslint-disable no-unused-vars */
const { x, y, r = 2 } = o;
/* eslint-enable no-unused-vars */
}
- bench.end(millions);
+ bench.end(n);
}
-function main({ millions, method }) {
+function main({ n, method }) {
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'normal':
- runNormal(millions);
+ runNormal(n);
break;
case 'destructureObject':
- runDestructured(millions);
+ runDestructured(n);
break;
default:
throw new Error(`Unexpected method "${method}"`);
diff --git a/benchmark/es/foreach-bench.js b/benchmark/es/foreach-bench.js
index e9179ed8de..25ea97b44d 100644
--- a/benchmark/es/foreach-bench.js
+++ b/benchmark/es/foreach-bench.js
@@ -5,51 +5,51 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, {
method: ['for', 'for-of', 'for-in', 'forEach'],
count: [5, 10, 20, 100],
- millions: [5]
+ n: [5e6]
});
-function useFor(millions, items, count) {
+function useFor(n, items, count) {
bench.start();
- for (var i = 0; i < millions * 1e6; i++) {
+ for (var i = 0; i < n; i++) {
for (var j = 0; j < count; j++) {
/* eslint-disable no-unused-vars */
const item = items[j];
/* esline-enable no-unused-vars */
}
}
- bench.end(millions);
+ bench.end(n);
}
-function useForOf(millions, items) {
+function useForOf(n, items) {
var item;
bench.start();
- for (var i = 0; i < millions * 1e6; i++) {
+ for (var i = 0; i < n; i++) {
for (item of items) {}
}
- bench.end(millions);
+ bench.end(n);
}
-function useForIn(millions, items) {
+function useForIn(n, items) {
bench.start();
- for (var i = 0; i < millions * 1e6; i++) {
+ for (var i = 0; i < n; i++) {
for (var j in items) {
/* eslint-disable no-unused-vars */
const item = items[j];
/* esline-enable no-unused-vars */
}
}
- bench.end(millions);
+ bench.end(n);
}
-function useForEach(millions, items) {
+function useForEach(n, items) {
bench.start();
- for (var i = 0; i < millions * 1e6; i++) {
+ for (var i = 0; i < n; i++) {
items.forEach((item) => {});
}
- bench.end(millions);
+ bench.end(n);
}
-function main({ millions, count, method }) {
+function main({ n, count, method }) {
const items = new Array(count);
var fn;
for (var i = 0; i < count; i++)
@@ -73,5 +73,5 @@ function main({ millions, count, method }) {
default:
throw new Error(`Unexpected method "${method}"`);
}
- fn(millions, items, count);
+ fn(n, items, count);
}
diff --git a/benchmark/es/map-bench.js b/benchmark/es/map-bench.js
index 445031aa98..d34010c6d5 100644
--- a/benchmark/es/map-bench.js
+++ b/benchmark/es/map-bench.js
@@ -8,62 +8,62 @@ const bench = common.createBenchmark(main, {
'object', 'nullProtoObject', 'nullProtoLiteralObject', 'storageObject',
'fakeMap', 'map'
],
- millions: [1]
+ n: [1e6]
});
-function runObject(millions) {
+function runObject(n) {
const m = {};
bench.start();
- for (var i = 0; i < millions * 1e6; i++) {
+ for (var i = 0; i < n; i++) {
m[`i${i}`] = i;
m[`s${i}`] = String(i);
assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]);
m[`i${i}`] = undefined;
m[`s${i}`] = undefined;
}
- bench.end(millions);
+ bench.end(n);
}
-function runNullProtoObject(millions) {
+function runNullProtoObject(n) {
const m = Object.create(null);
bench.start();
- for (var i = 0; i < millions * 1e6; i++) {
+ for (var i = 0; i < n; i++) {
m[`i${i}`] = i;
m[`s${i}`] = String(i);
assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]);
m[`i${i}`] = undefined;
m[`s${i}`] = undefined;
}
- bench.end(millions);
+ bench.end(n);
}
-function runNullProtoLiteralObject(millions) {
+function runNullProtoLiteralObject(n) {
const m = { __proto__: null };
bench.start();
- for (var i = 0; i < millions * 1e6; i++) {
+ for (var i = 0; i < n; i++) {
m[`i${i}`] = i;
m[`s${i}`] = String(i);
assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]);
m[`i${i}`] = undefined;
m[`s${i}`] = undefined;
}
- bench.end(millions);
+ bench.end(n);
}
function StorageObject() {}
StorageObject.prototype = Object.create(null);
-function runStorageObject(millions) {
+function runStorageObject(n) {
const m = new StorageObject();
bench.start();
- for (var i = 0; i < millions * 1e6; i++) {
+ for (var i = 0; i < n; i++) {
m[`i${i}`] = i;
m[`s${i}`] = String(i);
assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]);
m[`i${i}`] = undefined;
m[`s${i}`] = undefined;
}
- bench.end(millions);
+ bench.end(n);
}
function fakeMap() {
@@ -76,53 +76,53 @@ function fakeMap() {
};
}
-function runFakeMap(millions) {
+function runFakeMap(n) {
const m = fakeMap();
bench.start();
- for (var i = 0; i < millions * 1e6; i++) {
+ for (var i = 0; i < n; i++) {
m.set(`i${i}`, i);
m.set(`s${i}`, String(i));
assert.strictEqual(String(m.get(`i${i}`)), m.get(`s${i}`));
m.set(`i${i}`, undefined);
m.set(`s${i}`, undefined);
}
- bench.end(millions);
+ bench.end(n);
}
-function runMap(millions) {
+function runMap(n) {
const m = new Map();
bench.start();
- for (var i = 0; i < millions * 1e6; i++) {
+ for (var i = 0; i < n; i++) {
m.set(`i${i}`, i);
m.set(`s${i}`, String(i));
assert.strictEqual(String(m.get(`i${i}`)), m.get(`s${i}`));
m.set(`i${i}`, undefined);
m.set(`s${i}`, undefined);
}
- bench.end(millions);
+ bench.end(n);
}
-function main({ millions, method }) {
+function main({ n, method }) {
switch (method) {
case '':
// Empty string falls through to next line as default, mostly for tests.
case 'object':
- runObject(millions);
+ runObject(n);
break;
case 'nullProtoObject':
- runNullProtoObject(millions);
+ runNullProtoObject(n);
break;
case 'nullProtoLiteralObject':
- runNullProtoLiteralObject(millions);
+ runNullProtoLiteralObject(n);
break;
case 'storageObject':
- runStorageObject(millions);
+ runStorageObject(n);
break;
case 'fakeMap':
- runFakeMap(millions);
+ runFakeMap(n);
break;
case 'map':
- runMap(millions);
+ runMap(n);
break;
default:
throw new Error(`Unexpected method "${method}"`);
diff --git a/benchmark/es/restparams-bench.js b/benchmark/es/restparams-bench.js
index 6ad766f10f..d9b4878cb3 100644
--- a/benchmark/es/restparams-bench.js
+++ b/benchmark/es/restparams-bench.js
@@ -5,7 +5,7 @@ const assert = require('assert');
const bench = common.createBenchmark(main, {
method: ['copy', 'rest', 'arguments'],
- millions: [100]
+ n: [1e8]
});
function copyArguments() {
@@ -33,22 +33,22 @@ function useArguments() {
assert.strictEqual(arguments[3], 'b');
}
-function runCopyArguments(millions) {
- for (var i = 0; i < millions * 1e6; i++)
+function runCopyArguments(n) {
+ for (var i = 0; i < n; i++)
copyArguments(1, 2, 'a', 'b');
}
-function runRestArguments(millions) {
- for (var i = 0; i < millions * 1e6; i++)
+function runRestArguments(n) {
+ for (var i = 0; i < n; i++)
restArguments(1, 2, 'a', 'b');
}
-function runUseArguments(millions) {
- for (var i = 0; i < millions * 1e6; i++)
+function runUseArguments(n) {
+ for (var i = 0; i < n; i++)
useArguments(1, 2, 'a', 'b');
}
-function main({ millions, method }) {
+function main({ n, method }) {
var fn;
switch (method) {
case '':
@@ -66,6 +66,6 @@ function main({ millions, method }) {
throw new Error(`Unexpected method "${method}"`);
}
bench.start();
- fn(millions);
- bench.end(millions);
+ fn(n);
+ bench.end(n);
}
diff --git a/benchmark/es/spread-assign.js b/benchmark/es/spread-assign.js
index 00c634ff87..3246081ff7 100644
--- a/benchmark/es/spread-assign.js
+++ b/benchmark/es/spread-assign.js
@@ -6,11 +6,10 @@ const util = require('util');
const bench = common.createBenchmark(main, {
method: ['spread', 'assign', '_extend'],
count: [5, 10, 20],
- millions: [1]
+ n: [1e6]
});
-function main({ millions, context, count, rest, method }) {
- const n = millions * 1e6;
+function main({ n, context, count, rest, method }) {
const src = {};
for (let n = 0; n < count; n++)
diff --git a/benchmark/es/spread-bench.js b/benchmark/es/spread-bench.js
index 067299cd65..97c7596b6b 100644
--- a/benchmark/es/spread-bench.js
+++ b/benchmark/es/spread-bench.js
@@ -8,7 +8,7 @@ const bench = common.createBenchmark(main, {
count: [5, 10, 20],
context: ['context', 'null'],
rest: [0, 1],
- millions: [5]
+ n: [5e6]
});
function makeTest(count, rest) {
@@ -23,7 +23,7 @@ function makeTest(count, rest) {
}
}
-function main({ millions, context, count, rest, method }) {
+function main({ n, context, count, rest, method }) {
const ctx = context === 'context' ? {} : null;
var fn = makeTest(count, rest);
const args = new Array(count);
@@ -36,23 +36,23 @@ function main({ millions, context, count, rest, method }) {
// Empty string falls through to next line as default, mostly for tests.
case 'apply':
bench.start();
- for (i = 0; i < millions * 1e6; i++)
+ for (i = 0; i < n; i++)
fn.apply(ctx, args);
- bench.end(millions);
+ bench.end(n);
break;
case 'spread':
if (ctx !== null)
fn = fn.bind(ctx);
bench.start();
- for (i = 0; i < millions * 1e6; i++)
+ for (i = 0; i < n; i++)
fn(...args);
- bench.end(millions);
+ bench.end(n);
break;
case 'call-spread':
bench.start();
- for (i = 0; i < millions * 1e6; i++)
+ for (i = 0; i < n; i++)
fn.call(ctx, ...args);
- bench.end(millions);
+ bench.end(n);
break;
default:
throw new Error(`Unexpected method "${method}"`);
diff --git a/benchmark/misc/function_call/index.js b/benchmark/misc/function_call/index.js
index 28561bc48c..cafff3edc1 100644
--- a/benchmark/misc/function_call/index.js
+++ b/benchmark/misc/function_call/index.js
@@ -1,6 +1,6 @@
// show the difference between calling a short js function
// relative to a comparable C++ function.
-// Reports millions of calls per second.
+// Reports n of calls per second.
// Note that JS speed goes up, while cxx speed stays about the same.
'use strict';
@@ -28,14 +28,14 @@ assert(js() === cxx());
const bench = common.createBenchmark(main, {
type: ['js', 'cxx'],
- millions: [1, 10, 50]
+ n: [1e6, 1e7, 5e7]
});
-function main({ millions, type }) {
+function main({ n, type }) {
const fn = type === 'cxx' ? cxx : js;
bench.start();
- for (var i = 0; i < millions * 1e6; i++) {
+ for (var i = 0; i < n; i++) {
fn();
}
- bench.end(millions);
+ bench.end(n);
}
diff --git a/benchmark/misc/object-property-bench.js b/benchmark/misc/object-property-bench.js
index 3a181ed0a5..fae11119b6 100644
--- a/benchmark/misc/object-property-bench.js
+++ b/benchmark/misc/object-property-bench.js
@@ -6,7 +6,7 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, {
method: ['property', 'string', 'variable', 'symbol'],
- millions: [1000]
+ n: [1e9]
});
function runProperty(n) {
@@ -18,7 +18,7 @@ function runProperty(n) {
object.p2 = 21;
object.p1 += object.p2;
}
- bench.end(n / 1e6);
+ bench.end(n);
}
function runString(n) {
@@ -30,7 +30,7 @@ function runString(n) {
object['p2'] = 21;
object['p1'] += object['p2'];
}
- bench.end(n / 1e6);
+ bench.end(n);
}
function runVariable(n) {
@@ -44,7 +44,7 @@ function runVariable(n) {
object[var2] = 21;
object[var1] += object[var2];
}
- bench.end(n / 1e6);
+ bench.end(n);
}
function runSymbol(n) {
@@ -58,11 +58,10 @@ function runSymbol(n) {
object[symbol2] = 21;
object[symbol1] += object[symbol2];
}
- bench.end(n / 1e6);
+ bench.end(n);
}
-function main({ millions, method }) {
- const n = millions * 1e6;
+function main({ n, method }) {
switch (method) {
// '' is a default case for tests
diff --git a/benchmark/module/module-loader.js b/benchmark/module/module-loader.js
index 58d4dcf81c..c79e1a73d4 100644
--- a/benchmark/module/module-loader.js
+++ b/benchmark/module/module-loader.js
@@ -7,16 +7,15 @@ const tmpdir = require('../../test/common/tmpdir');
const benchmarkDirectory = path.join(tmpdir.path, 'nodejs-benchmark-module');
const bench = common.createBenchmark(main, {
- thousands: [50],
+ n: [5e4],
fullPath: ['true', 'false'],
useCache: ['true', 'false']
});
-function main({ thousands, fullPath, useCache }) {
+function main({ n, fullPath, useCache }) {
tmpdir.refresh();
try { fs.mkdirSync(benchmarkDirectory); } catch (e) {}
-
- for (var i = 0; i <= thousands * 1e3; i++) {
+ for (var i = 0; i <= n; i++) {
fs.mkdirSync(`${benchmarkDirectory}${i}`);
fs.writeFileSync(
`${benchmarkDirectory}${i}/package.json`,
@@ -29,37 +28,37 @@ function main({ thousands, fullPath, useCache }) {
}
if (fullPath === 'true')
- measureFull(thousands, useCache === 'true');
+ measureFull(n, useCache === 'true');
else
- measureDir(thousands, useCache === 'true');
+ measureDir(n, useCache === 'true');
tmpdir.refresh();
}
-function measureFull(thousands, useCache) {
+function measureFull(n, useCache) {
var i;
if (useCache) {
- for (i = 0; i <= thousands * 1e3; i++) {
+ for (i = 0; i <= n; i++) {
require(`${benchmarkDirectory}${i}/index.js`);
}
}
bench.start();
- for (i = 0; i <= thousands * 1e3; i++) {
+ for (i = 0; i <= n; i++) {
require(`${benchmarkDirectory}${i}/index.js`);
}
- bench.end(thousands);
+ bench.end(n);
}
-function measureDir(thousands, useCache) {
+function measureDir(n, useCache) {
var i;
if (useCache) {
- for (i = 0; i <= thousands * 1e3; i++) {
+ for (i = 0; i <= n; i++) {
require(`${benchmarkDirectory}${i}`);
}
}
bench.start();
- for (i = 0; i <= thousands * 1e3; i++) {
+ for (i = 0; i <= n; i++) {
require(`${benchmarkDirectory}${i}`);
}
- bench.end(thousands);
+ bench.end(n);
}
diff --git a/benchmark/process/next-tick-breadth-args.js b/benchmark/process/next-tick-breadth-args.js
index d759b955c4..6baa8d9960 100644
--- a/benchmark/process/next-tick-breadth-args.js
+++ b/benchmark/process/next-tick-breadth-args.js
@@ -2,36 +2,35 @@
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- millions: [4]
+ n: [4e6]
});
-function main({ millions }) {
- const N = millions * 1e6;
- var n = 0;
+function main({ n }) {
+ var j = 0;
function cb1(arg1) {
- n++;
- if (n === N)
- bench.end(n / 1e6);
+ j++;
+ if (j === n)
+ bench.end(n);
}
function cb2(arg1, arg2) {
- n++;
- if (n === N)
- bench.end(n / 1e6);
+ j++;
+ if (j === n)
+ bench.end(n);
}
function cb3(arg1, arg2, arg3) {
- n++;
- if (n === N)
- bench.end(n / 1e6);
+ j++;
+ if (j === n)
+ bench.end(n);
}
function cb4(arg1, arg2, arg3, arg4) {
- n++;
- if (n === N)
- bench.end(n / 1e6);
+ j++;
+ if (j === n)
+ bench.end(n);
}
bench.start();
- for (var i = 0; i < N; i++) {
+ for (var i = 0; i < n; i++) {
if (i % 4 === 0)
process.nextTick(cb4, 3.14, 1024, true, false);
else if (i % 3 === 0)
diff --git a/benchmark/process/next-tick-breadth.js b/benchmark/process/next-tick-breadth.js
index aebd623869..392d8e0209 100644
--- a/benchmark/process/next-tick-breadth.js
+++ b/benchmark/process/next-tick-breadth.js
@@ -2,21 +2,20 @@
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- millions: [4]
+ n: [4e6]
});
-function main({ millions }) {
- const N = millions * 1e6;
- var n = 0;
+function main({ n }) {
+ var j = 0;
function cb() {
- n++;
- if (n === N)
- bench.end(n / 1e6);
+ j++;
+ if (j === n)
+ bench.end(n);
}
bench.start();
- for (var i = 0; i < N; i++) {
+ for (var i = 0; i < n; i++) {
process.nextTick(cb);
}
}
diff --git a/benchmark/process/next-tick-depth-args.js b/benchmark/process/next-tick-depth-args.js
index 1c1b95bdc8..52d349c776 100644
--- a/benchmark/process/next-tick-depth-args.js
+++ b/benchmark/process/next-tick-depth-args.js
@@ -2,14 +2,12 @@
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- millions: [12]
+ n: [12e6]
});
process.maxTickDepth = Infinity;
-function main({ millions }) {
- var n = millions * 1e6;
-
+function main({ n }) {
function cb4(arg1, arg2, arg3, arg4) {
if (--n) {
if (n % 4 === 0)
@@ -21,7 +19,7 @@ function main({ millions }) {
else
process.nextTick(cb1, 0);
} else
- bench.end(millions);
+ bench.end(n);
}
function cb3(arg1, arg2, arg3) {
if (--n) {
@@ -34,7 +32,7 @@ function main({ millions }) {
else
process.nextTick(cb1, 0);
} else
- bench.end(millions);
+ bench.end(n);
}
function cb2(arg1, arg2) {
if (--n) {
@@ -47,7 +45,7 @@ function main({ millions }) {
else
process.nextTick(cb1, 0);
} else
- bench.end(millions);
+ bench.end(n);
}
function cb1(arg1) {
if (--n) {
@@ -60,7 +58,7 @@ function main({ millions }) {
else
process.nextTick(cb1, 0);
} else
- bench.end(millions);
+ bench.end(n);
}
bench.start();
process.nextTick(cb1, true);
diff --git a/benchmark/process/next-tick-depth.js b/benchmark/process/next-tick-depth.js
index 99fc83c377..6669936e39 100644
--- a/benchmark/process/next-tick-depth.js
+++ b/benchmark/process/next-tick-depth.js
@@ -1,13 +1,12 @@
'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- millions: [12]
+ n: [12e6]
});
process.maxTickDepth = Infinity;
-function main({ millions }) {
- var n = millions * 1e6;
+function main({ n }) {
bench.start();
process.nextTick(onNextTick);
@@ -15,6 +14,6 @@ function main({ millions }) {
if (--n)
process.nextTick(onNextTick);
else
- bench.end(millions);
+ bench.end(n);
}
}
diff --git a/benchmark/process/next-tick-exec-args.js b/benchmark/process/next-tick-exec-args.js
index 9e8ff73838..3be86cc08e 100644
--- a/benchmark/process/next-tick-exec-args.js
+++ b/benchmark/process/next-tick-exec-args.js
@@ -1,11 +1,10 @@
'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- millions: [5]
+ n: [5e6]
});
-function main({ millions }) {
- var n = millions * 1e6;
+function main({ n }) {
bench.start();
for (var i = 0; i < n; i++) {
@@ -20,6 +19,6 @@ function main({ millions }) {
}
function onNextTick(i) {
if (i + 1 === n)
- bench.end(millions);
+ bench.end(n);
}
}
diff --git a/benchmark/process/next-tick-exec.js b/benchmark/process/next-tick-exec.js
index a8897cd745..d00ee017de 100644
--- a/benchmark/process/next-tick-exec.js
+++ b/benchmark/process/next-tick-exec.js
@@ -1,11 +1,10 @@
'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- millions: [5]
+ n: [5e6]
});
-function main({ millions }) {
- var n = millions * 1e6;
+function main({ n }) {
bench.start();
for (var i = 0; i < n; i++) {
@@ -13,6 +12,6 @@ function main({ millions }) {
}
function onNextTick(i) {
if (i + 1 === n)
- bench.end(millions);
+ bench.end(n);
}
}
diff --git a/benchmark/streams/readable-bigread.js b/benchmark/streams/readable-bigread.js
index 62d1af874f..c3cff3d933 100644
--- a/benchmark/streams/readable-bigread.js
+++ b/benchmark/streams/readable-bigread.js
@@ -4,7 +4,7 @@ const common = require('../common');
const Readable = require('stream').Readable;
const bench = common.createBenchmark(main, {
- n: [100e1]
+ n: [1e3]
});
function main({ n }) {
diff --git a/benchmark/streams/readable-bigunevenread.js b/benchmark/streams/readable-bigunevenread.js
index e13769189a..95a4139c06 100644
--- a/benchmark/streams/readable-bigunevenread.js
+++ b/benchmark/streams/readable-bigunevenread.js
@@ -4,7 +4,7 @@ const common = require('../common');
const Readable = require('stream').Readable;
const bench = common.createBenchmark(main, {
- n: [100e1]
+ n: [1e3]
});
function main({ n }) {
diff --git a/benchmark/streams/readable-unevenread.js b/benchmark/streams/readable-unevenread.js
index f8b501ab47..690f1f4208 100644
--- a/benchmark/streams/readable-unevenread.js
+++ b/benchmark/streams/readable-unevenread.js
@@ -4,7 +4,7 @@ const common = require('../common');
const Readable = require('stream').Readable;
const bench = common.createBenchmark(main, {
- n: [100e1]
+ n: [1e3]
});
function main({ n }) {
diff --git a/benchmark/timers/immediate.js b/benchmark/timers/immediate.js
index 7ddb5cb05a..6a34becb91 100644
--- a/benchmark/timers/immediate.js
+++ b/benchmark/timers/immediate.js
@@ -2,30 +2,29 @@
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- thousands: [5000],
+ n: [5e6],
type: ['depth', 'depth1', 'breadth', 'breadth1', 'breadth4', 'clear']
});
-function main({ thousands, type }) {
- const N = thousands * 1e3;
+function main({ n, type }) {
switch (type) {
case 'depth':
- depth(N);
+ depth(n);
break;
case 'depth1':
- depth1(N);
+ depth1(n);
break;
case 'breadth':
- breadth(N);
+ breadth(n);
break;
case 'breadth1':
- breadth1(N);
+ breadth1(n);
break;
case 'breadth4':
- breadth4(N);
+ breadth4(n);
break;
case 'clear':
- clear(N);
+ clear(n);
break;
}
}
@@ -38,7 +37,7 @@ function depth(N) {
function cb() {
n++;
if (n === N)
- bench.end(N / 1e3);
+ bench.end(n);
else
setImmediate(cb);
}
@@ -52,7 +51,7 @@ function depth1(N) {
function cb(a1) {
n++;
if (n === N)
- bench.end(N / 1e3);
+ bench.end(N);
else
setImmediate(cb, 1);
}
@@ -65,7 +64,7 @@ function breadth(N) {
function cb() {
n++;
if (n === N)
- bench.end(N / 1e3);
+ bench.end(N);
}
for (var i = 0; i < N; i++) {
setImmediate(cb);
@@ -79,7 +78,7 @@ function breadth1(N) {
function cb(a1) {
n++;
if (n === N)
- bench.end(N / 1e3);
+ bench.end(n);
}
for (var i = 0; i < N; i++) {
setImmediate(cb, 1);
@@ -94,7 +93,7 @@ function breadth4(N) {
function cb(a1, a2, a3, a4) {
n++;
if (n === N)
- bench.end(N / 1e3);
+ bench.end(n);
}
for (var i = 0; i < N; i++) {
setImmediate(cb, 1, 2, 3, 4);
@@ -106,7 +105,7 @@ function clear(N) {
bench.start();
function cb(a1) {
if (a1 === 2)
- bench.end(N / 1e3);
+ bench.end(N);
}
for (var i = 0; i < N; i++) {
clearImmediate(setImmediate(cb, 1));
diff --git a/benchmark/timers/set-immediate-breadth-args.js b/benchmark/timers/set-immediate-breadth-args.js
index d5b5a98780..25147a5ea2 100644
--- a/benchmark/timers/set-immediate-breadth-args.js
+++ b/benchmark/timers/set-immediate-breadth-args.js
@@ -2,14 +2,13 @@
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- millions: [5]
+ n: [5e6]
});
-function main({ millions }) {
- const N = millions * 1e6;
+function main({ n }) {
process.on('exit', function() {
- bench.end(N / 1e6);
+ bench.end(n);
});
function cb1(arg1) {}
@@ -17,7 +16,7 @@ function main({ millions }) {
function cb3(arg1, arg2, arg3) {}
bench.start();
- for (let i = 0; i < N; i++) {
+ for (let i = 0; i < n; i++) {
if (i % 3 === 0)
setImmediate(cb3, 512, true, null, 512, true, null);
else if (i % 2 === 0)
diff --git a/benchmark/timers/set-immediate-breadth.js b/benchmark/timers/set-immediate-breadth.js
index 4f7d2cd276..44afe5aad9 100644
--- a/benchmark/timers/set-immediate-breadth.js
+++ b/benchmark/timers/set-immediate-breadth.js
@@ -2,20 +2,19 @@
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- millions: [10]
+ n: [1e7]
});
-function main({ millions }) {
- const N = millions * 1e6;
+function main({ n }) {
process.on('exit', function() {
- bench.end(millions);
+ bench.end(n);
});
function cb() {}
bench.start();
- for (let i = 0; i < N; i++) {
+ for (let i = 0; i < n; i++) {
setImmediate(cb);
}
}
diff --git a/benchmark/timers/set-immediate-depth-args.js b/benchmark/timers/set-immediate-depth-args.js
index aa5ec95f7d..2b18fcfd63 100644
--- a/benchmark/timers/set-immediate-depth-args.js
+++ b/benchmark/timers/set-immediate-depth-args.js
@@ -2,14 +2,13 @@
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- millions: [5]
+ n: [5e6]
});
-function main({ millions }) {
- const N = millions * 1e6;
+function main({ n }) {
process.on('exit', function() {
- bench.end(millions);
+ bench.end(n);
});
function cb3(n, arg2, arg3) {
@@ -43,5 +42,5 @@ function main({ millions }) {
}
}
bench.start();
- setImmediate(cb1, N);
+ setImmediate(cb1, n);
}
diff --git a/benchmark/timers/timers-breadth.js b/benchmark/timers/timers-breadth.js
index b05b3f91b1..8cd77f4fab 100644
--- a/benchmark/timers/timers-breadth.js
+++ b/benchmark/timers/timers-breadth.js
@@ -2,19 +2,18 @@
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- thousands: [5000],
+ n: [5e6],
});
-function main({ thousands }) {
- const N = thousands * 1e3;
- var n = 0;
+function main({ n }) {
+ var j = 0;
bench.start();
function cb() {
- n++;
- if (n === N)
- bench.end(N / 1e3);
+ j++;
+ if (j === n)
+ bench.end(n);
}
- for (var i = 0; i < N; i++) {
+ for (var i = 0; i < n; i++) {
setTimeout(cb, 1);
}
}
diff --git a/benchmark/timers/timers-cancel-pooled.js b/benchmark/timers/timers-cancel-pooled.js
index 3e262f820a..6f16f3c91d 100644
--- a/benchmark/timers/timers-cancel-pooled.js
+++ b/benchmark/timers/timers-cancel-pooled.js
@@ -3,14 +3,13 @@ const common = require('../common.js');
const assert = require('assert');
const bench = common.createBenchmark(main, {
- millions: [5],
+ n: [5e6],
});
-function main({ millions }) {
- const iterations = millions * 1e6;
+function main({ n }) {
var timer = setTimeout(() => {}, 1);
- for (var i = 0; i < iterations; i++) {
+ for (var i = 0; i < n; i++) {
setTimeout(cb, 1);
}
var next = timer._idlePrev;
@@ -18,13 +17,13 @@ function main({ millions }) {
bench.start();
- for (var j = 0; j < iterations; j++) {
+ for (var j = 0; j < n; j++) {
timer = next;
next = timer._idlePrev;
clearTimeout(timer);
}
- bench.end(iterations / 1e6);
+ bench.end(n);
}
function cb() {
diff --git a/benchmark/timers/timers-cancel-unpooled.js b/benchmark/timers/timers-cancel-unpooled.js
index 1586673113..7b46bad719 100644
--- a/benchmark/timers/timers-cancel-unpooled.js
+++ b/benchmark/timers/timers-cancel-unpooled.js
@@ -3,22 +3,21 @@ const common = require('../common.js');
const assert = require('assert');
const bench = common.createBenchmark(main, {
- millions: [1],
+ n: [1e6],
});
-function main({ millions }) {
- const iterations = millions * 1e6;
+function main({ n }) {
const timersList = [];
- for (var i = 0; i < iterations; i++) {
+ for (var i = 0; i < n; i++) {
timersList.push(setTimeout(cb, i + 1));
}
bench.start();
- for (var j = 0; j < iterations + 1; j++) {
+ for (var j = 0; j < n + 1; j++) {
clearTimeout(timersList[j]);
}
- bench.end(iterations / 1e6);
+ bench.end(n);
}
function cb() {
diff --git a/benchmark/timers/timers-depth.js b/benchmark/timers/timers-depth.js
index ca74eee393..bfc6dd02cf 100644
--- a/benchmark/timers/timers-depth.js
+++ b/benchmark/timers/timers-depth.js
@@ -2,18 +2,17 @@
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- thousands: [1],
+ n: [1e3],
});
-function main({ thousands }) {
- const N = thousands * 1e3;
- var n = 0;
+function main({ n }) {
+ var i = 0;
bench.start();
setTimeout(cb, 1);
function cb() {
- n++;
- if (n === N)
- bench.end(N / 1e3);
+ i++;
+ if (i === n)
+ bench.end(n);
else
setTimeout(cb, 1);
}
diff --git a/benchmark/timers/timers-insert-pooled.js b/benchmark/timers/timers-insert-pooled.js
index 59d2c490c3..a7441a9eaf 100644
--- a/benchmark/timers/timers-insert-pooled.js
+++ b/benchmark/timers/timers-insert-pooled.js
@@ -2,17 +2,16 @@
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- millions: [5],
+ n: [5e6],
});
-function main({ millions }) {
- const iterations = millions * 1e6;
+function main({ n }) {
bench.start();
- for (var i = 0; i < iterations; i++) {
+ for (var i = 0; i < n; i++) {
setTimeout(() => {}, 1);
}
- bench.end(iterations / 1e6);
+ bench.end(n);
}
diff --git a/benchmark/timers/timers-insert-unpooled.js b/benchmark/timers/timers-insert-unpooled.js
index fbbeebb759..1f1c5155a7 100644
--- a/benchmark/timers/timers-insert-unpooled.js
+++ b/benchmark/timers/timers-insert-unpooled.js
@@ -3,21 +3,19 @@ const common = require('../common.js');
const assert = require('assert');
const bench = common.createBenchmark(main, {
- millions: [1],
+ n: [1e6],
});
-function main({ millions }) {
- const iterations = millions * 1e6;
-
+function main({ n }) {
const timersList = [];
bench.start();
- for (var i = 0; i < iterations; i++) {
+ for (var i = 0; i < n; i++) {
timersList.push(setTimeout(cb, i + 1));
}
- bench.end(iterations / 1e6);
+ bench.end(n);
- for (var j = 0; j < iterations + 1; j++) {
+ for (var j = 0; j < n + 1; j++) {
clearTimeout(timersList[j]);
}
}
diff --git a/benchmark/timers/timers-timeout-pooled.js b/benchmark/timers/timers-timeout-pooled.js
index df88e2784f..d34080fa66 100644
--- a/benchmark/timers/timers-timeout-pooled.js
+++ b/benchmark/timers/timers-timeout-pooled.js
@@ -5,11 +5,10 @@ const common = require('../common.js');
// which then get executed on the next uv tick
const bench = common.createBenchmark(main, {
- millions: [10],
+ n: [1e7],
});
-function main({ millions }) {
- const iterations = millions * 1e6;
+function main({ n }) {
let count = 0;
// Function tracking on the hidden class in V8 can cause misleading
@@ -18,16 +17,16 @@ function main({ millions }) {
function cb() {
count++;
- if (count === iterations)
- bench.end(iterations / 1e6);
+ if (count === n)
+ bench.end(n);
}
function cb2() {
count++;
- if (count === iterations)
- bench.end(iterations / 1e6);
+ if (count === n)
+ bench.end(n);
}
- for (var i = 0; i < iterations; i++) {
+ for (var i = 0; i < n; i++) {
setTimeout(i % 2 ? cb : cb2, 1);
}