diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2017-01-12 20:03:29 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2017-01-23 21:30:18 +0800 |
commit | a647d82f83ad5ddad5db7be2cc24c3d686121792 (patch) | |
tree | 12bac723888bc85f29247f7942f5e2c247943a28 /benchmark/process | |
parent | 9fcd842279d8aee020c0a125db80641bb107ca36 (diff) | |
download | android-node-v8-a647d82f83ad5ddad5db7be2cc24c3d686121792.tar.gz android-node-v8-a647d82f83ad5ddad5db7be2cc24c3d686121792.tar.bz2 android-node-v8-a647d82f83ad5ddad5db7be2cc24c3d686121792.zip |
process: improve process.hrtime
* Add benchmarks for diffing a previous result
* Improvements to the documentation, including type annotation
* Update the outdated comments in src/node.cc, improve comments
in lib/internal/process.js
* Check the argument is an Array Tuple with length 2
PR-URL: https://github.com/nodejs/node/pull/10764
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Brian White <mscdex@mscdex.net>
Diffstat (limited to 'benchmark/process')
-rw-r--r-- | benchmark/process/bench-hrtime.js | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/benchmark/process/bench-hrtime.js b/benchmark/process/bench-hrtime.js index 661dff43b0..8a2920a238 100644 --- a/benchmark/process/bench-hrtime.js +++ b/benchmark/process/bench-hrtime.js @@ -1,18 +1,32 @@ 'use strict'; const common = require('../common'); +const assert = require('assert'); const bench = common.createBenchmark(main, { - n: [1e6] + n: [1e6], + type: ['raw', 'diff'] }); - function main(conf) { - const n = conf.n >>> 0; + const n = conf.n | 0; + const hrtime = process.hrtime; + var noDead = hrtime(); + var i; - bench.start(); - for (var i = 0; i < n; i++) { - process.hrtime(); + if (conf.type === 'raw') { + bench.start(); + for (i = 0; i < n; i++) { + noDead = hrtime(); + } + bench.end(n); + } else { + bench.start(); + for (i = 0; i < n; i++) { + noDead = hrtime(noDead); + } + bench.end(n); } - bench.end(n); + + assert.ok(Array.isArray(noDead)); } |