From e2133f3e572d62a97a3ea80cf181e32775e60499 Mon Sep 17 00:00:00 2001 From: Brian White Date: Sat, 25 Feb 2017 23:40:39 -0500 Subject: os: improve cpus() performance PR-URL: https://github.com/nodejs/node/pull/11564 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Jackson Tian --- benchmark/os/cpus.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 benchmark/os/cpus.js (limited to 'benchmark') 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); +} -- cgit v1.2.3