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-22 10:03:49 +0300
committerItalo A. Casas <me@italoacasas.com>2017-02-25 20:05:22 +0300
commit54e1f0c219827a8a17e0cab3fa0018e96562e9d1 (patch)
tree5670c45af9ca76d0ac6ef0e2b1f6c1757d17383c /benchmark
parent842ac583f6df969d40f7f875471c9851f1f14930 (diff)
process: improve memoryUsage() performance
Creating an object in JS and using a typed array to transfer values from C++ to JS is faster than creating an object and setting properties in C++. The included benchmark shows ~34% increase in performance with this change. PR-URL: https://github.com/nodejs/node/pull/11497 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/process/memoryUsage.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/benchmark/process/memoryUsage.js b/benchmark/process/memoryUsage.js
new file mode 100644
index 00000000000..d68ef339b4d
--- /dev/null
+++ b/benchmark/process/memoryUsage.js
@@ -0,0 +1,16 @@
+'use strict';
+
+var common = require('../common.js');
+var bench = common.createBenchmark(main, {
+ n: [1e5]
+});
+
+function main(conf) {
+ var n = +conf.n;
+
+ bench.start();
+ for (var i = 0; i < n; i++) {
+ process.memoryUsage();
+ }
+ bench.end(n);
+}