2016-02-20 02:03:16 +01:00
|
|
|
'use strict';
|
2017-09-14 03:48:53 +02:00
|
|
|
const common = require('../common.js');
|
|
|
|
const SlowBuffer = require('buffer').SlowBuffer;
|
2014-05-23 05:37:47 +02:00
|
|
|
|
2017-09-14 03:48:53 +02:00
|
|
|
const bench = common.createBenchmark(main, {
|
2014-05-23 05:37:47 +02:00
|
|
|
type: ['fast', 'slow'],
|
2019-03-04 01:34:00 +01:00
|
|
|
n: [1e6]
|
2014-05-23 05:37:47 +02:00
|
|
|
});
|
|
|
|
|
2017-09-14 03:48:53 +02:00
|
|
|
const buf = Buffer.allocUnsafe(1024);
|
|
|
|
const slowBuf = new SlowBuffer(1024);
|
2014-05-23 05:37:47 +02:00
|
|
|
|
2017-12-30 03:59:57 +01:00
|
|
|
function main({ n, type }) {
|
|
|
|
const b = type === 'fast' ? buf : slowBuf;
|
2014-05-23 05:37:47 +02:00
|
|
|
bench.start();
|
2019-03-04 01:34:00 +01:00
|
|
|
for (var i = 0; i < n; i++) {
|
2014-05-23 05:37:47 +02:00
|
|
|
b.slice(10, 256);
|
|
|
|
}
|
|
|
|
bench.end(n);
|
|
|
|
}
|