| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0db1f87 commit bd79c37
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,7 @@ | |||
| 2 | 2 | const common = require('../common.js'); | |
| 3 | 3 | ||
| 4 | 4 | const bench = common.createBenchmark(main, { | |
| 5 | - thousands: [2000], | ||
| 5 | + thousands: [5000], | ||
| 6 | 6 | type: ['depth', 'depth1', 'breadth', 'breadth1', 'breadth4', 'clear'] | |
| 7 | 7 | }); | |
| 8 | 8 | ||
@@ -88,6 +88,7 @@ function breadth1(N) { | |||
| 88 | 88 | ||
| 89 | 89 | // concurrent setImmediate, 4 arguments | |
| 90 | 90 | function breadth4(N) { | |
| 91 | + N /= 2; | ||
| 91 | 92 | var n = 0; | |
| 92 | 93 | bench.start(); | |
| 93 | 94 | function cb(a1, a2, a3, a4) { | |
@@ -101,6 +102,7 @@ function breadth4(N) { | |||
| 101 | 102 | } | |
| 102 | 103 | ||
| 103 | 104 | function clear(N) { | |
| 105 | + N *= 4; | ||
| 104 | 106 | bench.start(); | |
| 105 | 107 | function cb(a1) { | |
| 106 | 108 | if (a1 === 2) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,9 +19,9 @@ function main(conf) { | |||
| 19 | 19 | bench.start(); | |
| 20 | 20 | for (let i = 0; i < N; i++) { | |
| 21 | 21 | if (i % 3 === 0) | |
| 22 | - setImmediate(cb3, 512, true, null); | ||
| 22 | + setImmediate(cb3, 512, true, null, 512, true, null); | ||
| 23 | 23 | else if (i % 2 === 0) | |
| 24 | - setImmediate(cb2, false, 5.1); | ||
| 24 | + setImmediate(cb2, false, 5.1, 512); | ||
| 25 | 25 | else | |
| 26 | 26 | setImmediate(cb1, 0); | |
| 27 | 27 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | const common = require('../common.js'); | |
| 4 | 4 | const bench = common.createBenchmark(main, { | |
| 5 | - millions: [10] | ||
| 5 | + millions: [5] | ||
| 6 | 6 | }); | |
| 7 | 7 | ||
| 8 | 8 | function main(conf) { | |
@@ -15,29 +15,29 @@ function main(conf) { | |||
| 15 | 15 | function cb3(n, arg2, arg3) { | |
| 16 | 16 | if (--n) { | |
| 17 | 17 | if (n % 3 === 0) | |
| 18 | - setImmediate(cb3, n, true, null); | ||
| 18 | + setImmediate(cb3, n, true, null, 5.1, null, true); | ||
| 19 | 19 | else if (n % 2 === 0) | |
| 20 | - setImmediate(cb2, n, 5.1); | ||
| 20 | + setImmediate(cb2, n, 5.1, true); | ||
| 21 | 21 | else | |
| 22 | 22 | setImmediate(cb1, n); | |
| 23 | 23 | } | |
| 24 | 24 | } | |
| 25 | 25 | function cb2(n, arg2) { | |
| 26 | 26 | if (--n) { | |
| 27 | 27 | if (n % 3 === 0) | |
| 28 | - setImmediate(cb3, n, true, null); | ||
| 28 | + setImmediate(cb3, n, true, null, 5.1, null, true); | ||
| 29 | 29 | else if (n % 2 === 0) | |
| 30 | - setImmediate(cb2, n, 5.1); | ||
| 30 | + setImmediate(cb2, n, 5.1, true); | ||
| 31 | 31 | else | |
| 32 | 32 | setImmediate(cb1, n); | |
| 33 | 33 | } | |
| 34 | 34 | } | |
| 35 | 35 | function cb1(n) { | |
| 36 | 36 | if (--n) { | |
| 37 | 37 | if (n % 3 === 0) | |
| 38 | - setImmediate(cb3, n, true, null); | ||
| 38 | + setImmediate(cb3, n, true, null, 5.1, null, true); | ||
| 39 | 39 | else if (n % 2 === 0) | |
| 40 | - setImmediate(cb2, n, 5.1); | ||
| 40 | + setImmediate(cb2, n, 5.1, true); | ||
| 41 | 41 | else | |
| 42 | 42 | setImmediate(cb1, n); | |
| 43 | 43 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,7 @@ | |||
| 2 | 2 | const common = require('../common.js'); | |
| 3 | 3 | ||
| 4 | 4 | const bench = common.createBenchmark(main, { | |
| 5 | - thousands: [500], | ||
| 5 | + thousands: [5000], | ||
| 6 | 6 | }); | |
| 7 | 7 | ||
| 8 | 8 | function main(conf) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,11 +3,11 @@ const common = require('../common.js'); | |||
| 3 | 3 | const assert = require('assert'); | |
| 4 | 4 | ||
| 5 | 5 | const bench = common.createBenchmark(main, { | |
| 6 | - thousands: [500], | ||
| 6 | + millions: [5], | ||
| 7 | 7 | }); | |
| 8 | 8 | ||
| 9 | 9 | function main(conf) { | |
| 10 | - const iterations = +conf.thousands * 1e3; | ||
| 10 | + const iterations = +conf.millions * 1e6; | ||
| 11 | 11 | ||
| 12 | 12 | var timer = setTimeout(() => {}, 1); | |
| 13 | 13 | for (var i = 0; i < iterations; i++) { | |
@@ -24,7 +24,7 @@ function main(conf) { | |||
| 24 | 24 | clearTimeout(timer); | |
| 25 | 25 | } | |
| 26 | 26 | ||
| 27 | - bench.end(iterations / 1e3); | ||
| 27 | + bench.end(iterations / 1e6); | ||
| 28 | 28 | } | |
| 29 | 29 | ||
| 30 | 30 | function cb() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,11 +3,11 @@ const common = require('../common.js'); | |||
| 3 | 3 | const assert = require('assert'); | |
| 4 | 4 | ||
| 5 | 5 | const bench = common.createBenchmark(main, { | |
| 6 | - thousands: [100], | ||
| 6 | + millions: [1], | ||
| 7 | 7 | }); | |
| 8 | 8 | ||
| 9 | 9 | function main(conf) { | |
| 10 | - const iterations = +conf.thousands * 1e3; | ||
| 10 | + const iterations = +conf.millions * 1e6; | ||
| 11 | 11 | ||
| 12 | 12 | const timersList = []; | |
| 13 | 13 | for (var i = 0; i < iterations; i++) { | |
@@ -18,7 +18,7 @@ function main(conf) { | |||
| 18 | 18 | for (var j = 0; j < iterations + 1; j++) { | |
| 19 | 19 | clearTimeout(timersList[j]); | |
| 20 | 20 | } | |
| 21 | - bench.end(iterations / 1e3); | ||
| 21 | + bench.end(iterations / 1e6); | ||
| 22 | 22 | } | |
| 23 | 23 | ||
| 24 | 24 | function cb() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,17 +2,17 @@ | |||
| 2 | 2 | const common = require('../common.js'); | |
| 3 | 3 | ||
| 4 | 4 | const bench = common.createBenchmark(main, { | |
| 5 | - thousands: [500], | ||
| 5 | + millions: [5], | ||
| 6 | 6 | }); | |
| 7 | 7 | ||
| 8 | 8 | function main(conf) { | |
| 9 | - const iterations = +conf.thousands * 1e3; | ||
| 9 | + const iterations = +conf.millions * 1e6; | ||
| 10 | 10 | ||
| 11 | 11 | bench.start(); | |
| 12 | 12 | ||
| 13 | 13 | for (var i = 0; i < iterations; i++) { | |
| 14 | 14 | setTimeout(() => {}, 1); | |
| 15 | 15 | } | |
| 16 | 16 | ||
| 17 | - bench.end(iterations / 1e3); | ||
| 17 | + bench.end(iterations / 1e6); | ||
| 18 | 18 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,19 +3,19 @@ const common = require('../common.js'); | |||
| 3 | 3 | const assert = require('assert'); | |
| 4 | 4 | ||
| 5 | 5 | const bench = common.createBenchmark(main, { | |
| 6 | - thousands: [100], | ||
| 6 | + millions: [1], | ||
| 7 | 7 | }); | |
| 8 | 8 | ||
| 9 | 9 | function main(conf) { | |
| 10 | - const iterations = +conf.thousands * 1e3; | ||
| 10 | + const iterations = +conf.millions * 1e6; | ||
| 11 | 11 | ||
| 12 | 12 | const timersList = []; | |
| 13 | 13 | ||
| 14 | 14 | bench.start(); | |
| 15 | 15 | for (var i = 0; i < iterations; i++) { | |
| 16 | 16 | timersList.push(setTimeout(cb, i + 1)); | |
| 17 | 17 | } | |
| 18 | - bench.end(iterations / 1e3); | ||
| 18 | + bench.end(iterations / 1e6); | ||
| 19 | 19 | ||
| 20 | 20 | for (var j = 0; j < iterations + 1; j++) { | |
| 21 | 21 | clearTimeout(timersList[j]); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,23 +1,35 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common.js'); | |
| 3 | 3 | ||
| 4 | + // The following benchmark measures setting up n * 1e6 timeouts, | ||
| 5 | + // which then get executed on the next uv tick | ||
| 6 | + | ||
| 4 | 7 | const bench = common.createBenchmark(main, { | |
| 5 | - thousands: [500], | ||
| 8 | + millions: [10], | ||
| 6 | 9 | }); | |
| 7 | 10 | ||
| 8 | 11 | function main(conf) { | |
| 9 | - const iterations = +conf.thousands * 1e3; | ||
| 10 | - var count = 0; | ||
| 12 | + const iterations = +conf.millions * 1e6; | ||
| 13 | + let count = 0; | ||
| 11 | 14 | ||
| 12 | - for (var i = 0; i < iterations; i++) { | ||
| 13 | - setTimeout(cb, 1); | ||
| 14 | - } | ||
| 15 | - | ||
| 16 | - bench.start(); | ||
| 15 | + // Function tracking on the hidden class in V8 can cause misleading | ||
| 16 | + // results in this benchmark if only a single function is used — | ||
| 17 | + // alternate between two functions for a fairer benchmark | ||
| 17 | 18 | ||
| 18 | 19 | function cb() { | |
| 19 | 20 | count++; | |
| 20 | 21 | if (count === iterations) | |
| 21 | - bench.end(iterations / 1e3); | ||
| 22 | + bench.end(iterations / 1e6); | ||
| 22 | 23 | } | |
| 24 | + function cb2() { | ||
| 25 | + count++; | ||
| 26 | + if (count === iterations) | ||
| 27 | + bench.end(iterations / 1e6); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + for (var i = 0; i < iterations; i++) { | ||
| 31 | + setTimeout(i % 2 ? cb : cb2, 1); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + bench.start(); | ||
| 23 | 35 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments