join vs replace

Benchmark created on


Setup

const arr = 'a'.repeat(1000).split('');

Test runner

Ready to run.

Testing in
TestOps/sec
a
let buffer = arr.join('\0');

for(let i = 0; i < 1000; i++) {
	buffer = buffer.replace(/\0/, i)
}
ready
b
let buffer = '';

for(let i = 0; i < 1000; i++) {
	buffer += i
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.