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/misc | |
parent | 44be55fc4e490975eb3292dca12cfac1eec234bd (diff) | |
download | node-new-f7a4ccb409c14fed9c52956765c95b10bacb779a.tar.gz |
bench: Move nexttick-2 to misc/next-tick-depth
x
Diffstat (limited to 'benchmark/misc')
-rw-r--r-- | benchmark/misc/next-tick-depth.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/benchmark/misc/next-tick-depth.js b/benchmark/misc/next-tick-depth.js new file mode 100644 index 0000000000..b8ae27879e --- /dev/null +++ b/benchmark/misc/next-tick-depth.js @@ -0,0 +1,40 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var common = require('../common.js'); +var bench = common.createBenchmark(main, { + millions: [2] +}); + +process.maxTickDepth = Infinity; + +function main(conf) { + var n = +conf.millions * 1e6; + + bench.start(); + process.nextTick(onNextTick); + function onNextTick() { + if (--n) + process.nextTick(onNextTick); + else + bench.end(+conf.millions); + } +} |