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-12-07 17:06:30 +01:00
|
|
|
const bench = common.createBenchmark(main, {
|
|
|
|
n: [32],
|
|
|
|
});
|
2015-07-15 22:09:52 +02:00
|
|
|
|
2017-12-30 03:59:57 +01:00
|
|
|
function main({ n }) {
|
2016-03-03 22:45:08 +01:00
|
|
|
const s = 'abcd'.repeat(8 << 20);
|
2017-03-13 19:50:57 +01:00
|
|
|
// eslint-disable-next-line no-unescaped-regexp-dot
|
2015-07-15 22:09:52 +02:00
|
|
|
s.match(/./); // Flatten string.
|
2016-11-24 20:43:35 +01:00
|
|
|
assert.strictEqual(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();
|
2016-12-07 17:06:30 +01:00
|
|
|
for (var i = 0; i < n; i += 1) b.base64Write(s, 0, s.length);
|
|
|
|
bench.end(n);
|
2015-07-15 22:09:52 +02:00
|
|
|
}
|