diff options
author | Jeremiah Senkpiel <fishrock123@rocketmail.com> | 2017-01-20 16:16:26 -0500 |
---|---|---|
committer | Jeremiah Senkpiel <fishrock123@rocketmail.com> | 2017-01-27 14:26:24 -0500 |
commit | c74e6fe651a763f9c6be00a2908af8b703bd5976 (patch) | |
tree | 49839f5d717ea9636e36f36bf71a89a4e65abf74 /benchmark/timers/timers-insert-unpooled.js | |
parent | b19334e566650c381c4a49277b214f6ebcc55001 (diff) | |
download | android-node-v8-c74e6fe651a763f9c6be00a2908af8b703bd5976.tar.gz android-node-v8-c74e6fe651a763f9c6be00a2908af8b703bd5976.tar.bz2 android-node-v8-c74e6fe651a763f9c6be00a2908af8b703bd5976.zip |
benchmark: add more thorough timers benchmarks
Refs: https://github.com/nodejs/node/issues/9493
PR-URL: https://github.com/nodejs/node/pull/10925
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'benchmark/timers/timers-insert-unpooled.js')
-rw-r--r-- | benchmark/timers/timers-insert-unpooled.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/benchmark/timers/timers-insert-unpooled.js b/benchmark/timers/timers-insert-unpooled.js new file mode 100644 index 0000000000..91eabeb04e --- /dev/null +++ b/benchmark/timers/timers-insert-unpooled.js @@ -0,0 +1,27 @@ +'use strict'; +var common = require('../common.js'); +var assert = require('assert'); + +var bench = common.createBenchmark(main, { + thousands: [100], +}); + +function main(conf) { + var iterations = +conf.thousands * 1e3; + + var timersList = []; + + bench.start(); + for (var i = 0; i < iterations; i++) { + timersList.push(setTimeout(cb, i + 1)); + } + bench.end(iterations / 1e3); + + for (var j = 0; j < iterations + 1; j++) { + clearTimeout(timersList[j]); + } +} + +function cb() { + assert(false, 'Timer ' + this._idleTimeout + ' should not call callback'); +} |