1'use strict'; 2const common = require('../common.js'); 3const SlowBuffer = require('buffer').SlowBuffer; 4 5const bench = common.createBenchmark(main, { 6 type: ['fast', 'slow'], 7 n: [1e6] 8}); 9 10const buf = Buffer.allocUnsafe(1024); 11const slowBuf = new SlowBuffer(1024); 12 13function main({ n, type }) { 14 const b = type === 'fast' ? buf : slowBuf; 15 bench.start(); 16 for (let i = 0; i < n; i++) { 17 b.slice(10, 256); 18 } 19 bench.end(n); 20} 21