-
-
Save chrisdickinson/5fbcbd3843078bc31bdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const common = require('../common.js'); | |
const bench = common.createBenchmark(main, { | |
range: [0x7F, 0x7FF, 0x7FFF], | |
size: [1<<14, 1<<16, 1<<20] | |
}); | |
function main(conf) { | |
let arr = new Array(Number(conf.size)) | |
fillBuffer(Number(conf.range), arr) | |
measure(new Buffer(arr)) | |
} | |
function measure(buf) { | |
bench.start() | |
let size = buf.stripInvalidUtf8() // added this – runs Utf8Value::StripInvalidUtf8 on the buffer data | |
bench.end(1, buf.slice(0, size).length) | |
} | |
function fillBuffer(range, out) { | |
for (let i = 0; i < out.length; ++i) { | |
out[i] = String.fromCodePoint(i % range) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment