diff options
author | isaacs <i@izs.me> | 2013-02-11 22:50:30 -0800 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-02-19 14:14:34 -0800 |
commit | f7a4ccb409c14fed9c52956765c95b10bacb779a (patch) | |
tree | 81c1d1ec61e2ea561b0d9bdbf00702a9fa271e8b /benchmark | |
parent | 44be55fc4e490975eb3292dca12cfac1eec234bd (diff) | |
download | android-node-v8-f7a4ccb409c14fed9c52956765c95b10bacb779a.tar.gz android-node-v8-f7a4ccb409c14fed9c52956765c95b10bacb779a.tar.bz2 android-node-v8-f7a4ccb409c14fed9c52956765c95b10bacb779a.zip |
bench: Move nexttick-2 to misc/next-tick-depth
x
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/misc/next-tick-depth.js (renamed from benchmark/next-tick-2.js) | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/benchmark/next-tick-2.js b/benchmark/misc/next-tick-depth.js index 44a2b41b54..b8ae27879e 100644 --- a/benchmark/next-tick-2.js +++ b/benchmark/misc/next-tick-depth.js @@ -19,23 +19,22 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -var count = 2e6, - left = count, - start; +var common = require('../common.js'); +var bench = common.createBenchmark(main, { + millions: [2] +}); -function onNextTick() { - if (--left) { - process.nextTick(onNextTick); - } else { - finalize(); - } -} +process.maxTickDepth = Infinity; -function finalize() { - var duration = (new Date()).getTime() - start, - ticksPerSec = count / duration * 1000; - console.log("nextTick callbacks per second: " + Math.round(ticksPerSec)); -} +function main(conf) { + var n = +conf.millions * 1e6; -start = (new Date()).getTime(); -process.nextTick(onNextTick); + bench.start(); + process.nextTick(onNextTick); + function onNextTick() { + if (--n) + process.nextTick(onNextTick); + else + bench.end(+conf.millions); + } +} |