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:
-rw-r--r--benchmark/buffers/buffer-slice.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/benchmark/buffers/buffer-slice.js b/benchmark/buffers/buffer-slice.js
index a64cbd2ab2d..dcb18754e84 100644
--- a/benchmark/buffers/buffer-slice.js
+++ b/benchmark/buffers/buffer-slice.js
@@ -3,7 +3,7 @@ const common = require('../common.js');
const SlowBuffer = require('buffer').SlowBuffer;
const bench = common.createBenchmark(main, {
- type: ['fast', 'slow'],
+ type: ['fast', 'slow', 'subarray'],
n: [1e6]
});
@@ -11,10 +11,14 @@ const buf = Buffer.allocUnsafe(1024);
const slowBuf = new SlowBuffer(1024);
function main({ n, type }) {
- const b = type === 'fast' ? buf : slowBuf;
+ const b = type === 'slow' ? slowBuf : buf;
+ const fn = type === 'subarray' ?
+ () => b.subarray(10, 256) :
+ () => b.slice(10, 256);
+
bench.start();
for (let i = 0; i < n; i++) {
- b.slice(10, 256);
+ fn();
}
bench.end(n);
}