summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorBrian White <mscdex@mscdex.net>2016-12-24 19:50:05 -0500
committerJames M Snell <jasnell@gmail.com>2016-12-27 14:57:06 -0800
commit13a4887ee94d61d990dd22100aa7c17c39e3200a (patch)
tree048782ef83285583a7010e2d6c57d27d37cc9707 /benchmark
parent595b22affad1c87574f7d266ecf4159b1d30da04 (diff)
downloadandroid-node-v8-13a4887ee94d61d990dd22100aa7c17c39e3200a.tar.gz
android-node-v8-13a4887ee94d61d990dd22100aa7c17c39e3200a.tar.bz2
android-node-v8-13a4887ee94d61d990dd22100aa7c17c39e3200a.zip
buffer: improve allocation performance
assertSize() is adjusted to be inlineable according to V8's default function size limits when determining inlineability. This results in up to 11% performance gains when allocating any kind of Buffer. Avoid avoids use of in, resulting in ~50% improvement when creating a Buffer from an array-like object. PR-URL: https://github.com/nodejs/node/pull/10443 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/buffers/buffer-from.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/benchmark/buffers/buffer-from.js b/benchmark/buffers/buffer-from.js
index c35a0f23e0..c7889b2ec6 100644
--- a/benchmark/buffers/buffer-from.js
+++ b/benchmark/buffers/buffer-from.js
@@ -10,7 +10,8 @@ const bench = common.createBenchmark(main, {
'buffer',
'uint8array',
'string',
- 'string-base64'
+ 'string-base64',
+ 'object'
],
len: [10, 2048],
n: [1024]
@@ -25,6 +26,7 @@ function main(conf) {
const str = 'a'.repeat(len);
const buffer = Buffer.allocUnsafe(len);
const uint8array = new Uint8Array(len);
+ const obj = { length: null }; // Results in a new, empty Buffer
var i;
@@ -80,6 +82,13 @@ function main(conf) {
}
bench.end(n);
break;
+ case 'object':
+ bench.start();
+ for (i = 0; i < n * 1024; i++) {
+ Buffer.from(obj);
+ }
+ bench.end(n);
+ break;
default:
assert.fail(null, null, 'Should not get here');
}