summaryrefslogtreecommitdiff
path: root/benchmark/es
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/es')
-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
8 files changed, 91 insertions, 92 deletions
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}"`);