aboutsummaryrefslogtreecommitdiff
path: root/benchmark/timers/timers-cancel-unpooled.js
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/timers/timers-cancel-unpooled.js')
-rw-r--r--benchmark/timers/timers-cancel-unpooled.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/benchmark/timers/timers-cancel-unpooled.js b/benchmark/timers/timers-cancel-unpooled.js
index 7b46bad719..1daf68bde0 100644
--- a/benchmark/timers/timers-cancel-unpooled.js
+++ b/benchmark/timers/timers-cancel-unpooled.js
@@ -4,18 +4,26 @@ const assert = require('assert');
const bench = common.createBenchmark(main, {
n: [1e6],
+ direction: ['start', 'end']
});
-function main({ n }) {
+function main({ n, direction }) {
const timersList = [];
for (var i = 0; i < n; i++) {
timersList.push(setTimeout(cb, i + 1));
}
+ var j;
bench.start();
- for (var j = 0; j < n + 1; j++) {
- clearTimeout(timersList[j]);
+ if (direction === 'start') {
+ for (j = 0; j < n; j++) {
+ clearTimeout(timersList[j]);
+ }
+ } else {
+ for (j = n - 1; j >= 0; j--) {
+ clearTimeout(timersList[j]);
+ }
}
bench.end(n);
}