Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian White <mscdex@mscdex.net>2017-02-26 07:40:39 +0300
committerAnna Henningsen <anna@addaleax.net>2017-03-06 01:24:54 +0300
commite2133f3e572d62a97a3ea80cf181e32775e60499 (patch)
treef3044f16948c07a1b1e33fd6fa9038c4dffbc7c2 /benchmark
parentac3deb14812c170d6a7b53c4ed566862386bc23e (diff)
os: improve cpus() performance
PR-URL: https://github.com/nodejs/node/pull/11564 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/os/cpus.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/benchmark/os/cpus.js b/benchmark/os/cpus.js
new file mode 100644
index 00000000000..2a8535113c2
--- /dev/null
+++ b/benchmark/os/cpus.js
@@ -0,0 +1,17 @@
+'use strict';
+
+const common = require('../common.js');
+const cpus = require('os').cpus;
+
+const bench = common.createBenchmark(main, {
+ n: [3e4]
+});
+
+function main(conf) {
+ const n = +conf.n;
+
+ bench.start();
+ for (var i = 0; i < n; ++i)
+ cpus();
+ bench.end(n);
+}