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'],
|
|
|
|
n: [1024]
|
|
|
|
});
|
|
|
|
|
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();
|
|
|
|
for (var i = 0; i < n * 1024; i++) {
|
|
|
|
b.slice(10, 256);
|
|
|
|
}
|
|
|
|
bench.end(n);
|
|
|
|
}
|