Concatenation vs .join()

Benchmark created on


Setup

window.quickHash = (i) => {
  return (i * 2654435761 >>> 0).toString(36)
}

window.strings = []
window.string = ""

Teardown

delete window.strings
delete window.string

Test runner

Ready to run.

Testing in
TestOps/sec
Concatenation
for (let i = 0; i < 1e7; i += 1) {
	window.string += window.quickHash(i)
}

console.log(window.string)
ready
.join()
for (let i = 0; i < 1e7; i += 1) {
	window.strings.push(window.quickHash(i))
}

console.log(window.strings.join(''))
ready

Revisions

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