diff options
| author | Trevor Norris <trev.norris@gmail.com> | 2015-10-14 14:58:52 -0600 |
|---|---|---|
| committer | Trevor Norris <trev.norris@gmail.com> | 2015-10-21 16:57:05 -0600 |
| commit | 494227bb03df3fff4a59b58f86498ab262e7d46d (patch) | |
| tree | 488cb9d0c85124f411b50ca4b466605737dea32c /test/parallel/test-process-getactiverequests.js | |
| parent | b354be7761ffb7b8b2deb5c5811831874835d6df (diff) | |
| download | node-new-494227bb03df3fff4a59b58f86498ab262e7d46d.tar.gz | |
node: improve GetActiveRequests performance
v8 is faster at setting object properties in JS than C++. Even when it
requires calling into JS from native code. Make
process._getActiveRequests() faster by doing this when populating the
array containing request objects.
Simple benchmark:
for (let i = 0; i < 22; i++)
fs.open(__filename, 'r', function() { });
let t = process.hrtime();
for (let i = 0; i < 1e6; i++)
process._getActiveRequests();
t = process.hrtime(t);
console.log((t[0] * 1e9 + t[1]) / 1e6);
Results between the two:
Previous: 4406 ns/op
Patched: 690 ns/op 5.4x faster
PR-URL: https://github.com/nodejs/node/pull/3375
Reviewed-By: James Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <ben@strongloop.com>
Diffstat (limited to 'test/parallel/test-process-getactiverequests.js')
| -rw-r--r-- | test/parallel/test-process-getactiverequests.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/parallel/test-process-getactiverequests.js b/test/parallel/test-process-getactiverequests.js new file mode 100644 index 0000000000..4b7e0df1a5 --- /dev/null +++ b/test/parallel/test-process-getactiverequests.js @@ -0,0 +1,10 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); + +for (let i = 0; i < 12; i++) + fs.open(__filename, 'r', function() { }); + +assert.equal(12, process._getActiveRequests().length); |
