2016-02-20 02:03:16 +01:00
|
|
|
'use strict';
|
2016-03-03 22:45:08 +01:00
|
|
|
const assert = require('assert');
|
|
|
|
const common = require('../common.js');
|
2015-07-15 22:09:52 +02:00
|
|
|
|
2016-03-03 22:45:08 +01:00
|
|
|
const bench = common.createBenchmark(main, {});
|
2015-07-15 22:09:52 +02:00
|
|
|
|
|
|
|
function main(conf) {
|
2016-03-03 22:45:08 +01:00
|
|
|
const s = 'abcd'.repeat(8 << 20);
|
2015-07-15 22:09:52 +02:00
|
|
|
s.match(/./); // Flatten string.
|
|
|
|
assert.equal(s.length % 4, 0);
|
2016-01-26 00:00:06 +01:00
|
|
|
const b = Buffer.allocUnsafe(s.length / 4 * 3);
|
2015-07-15 22:09:52 +02:00
|
|
|
b.write(s, 0, s.length, 'base64');
|
|
|
|
bench.start();
|
|
|
|
for (var i = 0; i < 32; i += 1) b.base64Write(s, 0, s.length);
|
|
|
|
bench.end(32);
|
|
|
|
}
|