diff --git a/benchmark/timers/timers-breadth.js b/benchmark/timers/timers-breadth.js new file mode 100644 index 00000000000000..1101ee7dbf8907 --- /dev/null +++ b/benchmark/timers/timers-breadth.js @@ -0,0 +1,20 @@ +'use strict'; +var common = require('../common.js'); + +var bench = common.createBenchmark(main, { + thousands: [500], +}); + +function main(conf) { + var N = +conf.thousands * 1e3; + var n = 0; + bench.start(); + function cb() { + n++; + if (n === N) + bench.end(N / 1e3); + } + for (var i = 0; i < N; i++) { + setTimeout(cb, 1); + } +} diff --git a/benchmark/timers/timers-depth.js b/benchmark/timers/timers-depth.js new file mode 100644 index 00000000000000..d5efc5c672d502 --- /dev/null +++ b/benchmark/timers/timers-depth.js @@ -0,0 +1,20 @@ +'use strict'; +var common = require('../common.js'); + +var bench = common.createBenchmark(main, { + thousands: [1], +}); + +function main(conf) { + var N = +conf.thousands * 1e3; + var n = 0; + bench.start(); + setTimeout(cb, 1); + function cb() { + n++; + if (n === N) + bench.end(N / 1e3); + else + setTimeout(cb, 1); + } +} diff --git a/benchmark/timers/timers.js b/benchmark/timers/timers.js deleted file mode 100644 index 13b18fffc5ead7..00000000000000 --- a/benchmark/timers/timers.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; -var common = require('../common.js'); - -var bench = common.createBenchmark(main, { - thousands: [500], - type: ['depth', 'breadth'] -}); - -function main(conf) { - var n = +conf.thousands * 1e3; - if (conf.type === 'breadth') - breadth(n); - else - depth(n); -} - -function depth(N) { - var n = 0; - bench.start(); - setTimeout(cb); - function cb() { - n++; - if (n === N) - bench.end(N / 1e3); - else - setTimeout(cb); - } -} - -function breadth(N) { - var n = 0; - bench.start(); - function cb() { - n++; - if (n === N) - bench.end(N / 1e3); - } - for (var i = 0; i < N; i++) { - setTimeout(cb); - } -}