node/benchmark/buffers/buffer-base64-encode.js
Rich Trott 4bb529d972 benchmark: use strict mode
Apply strict mode to benchmark code.

PR-URL: https://github.com/nodejs/node/pull/5336
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-02-22 11:09:26 -08:00

16 lines
399 B
JavaScript

'use strict';
var common = require('../common.js');
var bench = common.createBenchmark(main, {});
function main(conf) {
var N = 64 * 1024 * 1024;
var b = Buffer(N);
var s = '';
for (var i = 0; i < 256; ++i) s += String.fromCharCode(i);
for (var i = 0; i < N; i += 256) b.write(s, i, 256, 'ascii');
bench.start();
for (var i = 0; i < 32; ++i) b.toString('base64');
bench.end(64);
}