summaryrefslogtreecommitdiff
path: root/benchmark/timers
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/timers')
-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
11 files changed, 65 insertions, 77 deletions
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);
}