char string vs array

Benchmark created on


Setup

let charSetStr = "";
const charSetArr = [];

for (let index = 32; index < 127; index++) {
	charSetStr += String.fromCharCode(index);
	charSetArr.push(String.fromCharCode(index));
}

const charSetLen = charSetStr.length;

Test runner

Ready to run.

Testing in
TestOps/sec
char string
for (let index = 0; index < charSetLen; index++) {
	const value = charSetStr[index];
}
ready
char array
for (let index = 0; index < charSetLen; index++) {
	const value = charSetArr[index];
}
ready

Revisions

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