2016-02-20 02:03:16 +01:00
|
|
|
'use strict';
|
2013-02-11 22:37:24 +01:00
|
|
|
var common = require('../common.js');
|
|
|
|
|
2016-12-07 17:06:30 +01:00
|
|
|
const bench = common.createBenchmark(main, {
|
|
|
|
len: [64 * 1024 * 1024],
|
|
|
|
n: [32]
|
|
|
|
});
|
2013-02-11 22:37:24 +01:00
|
|
|
|
|
|
|
function main(conf) {
|
2016-12-07 17:06:30 +01:00
|
|
|
const n = +conf.n;
|
|
|
|
const len = +conf.len;
|
|
|
|
const b = Buffer.allocUnsafe(len);
|
|
|
|
let s = '';
|
|
|
|
let i;
|
2016-02-28 06:56:18 +01:00
|
|
|
for (i = 0; i < 256; ++i) s += String.fromCharCode(i);
|
2016-12-07 17:06:30 +01:00
|
|
|
for (i = 0; i < len; i += 256) b.write(s, i, 256, 'ascii');
|
2014-06-04 15:25:09 +02:00
|
|
|
bench.start();
|
2016-12-07 17:06:30 +01:00
|
|
|
for (i = 0; i < n; ++i) b.toString('base64');
|
|
|
|
bench.end(n);
|
2013-02-11 22:37:24 +01:00
|
|
|
}
|