Single character comparison speeds: String comparison vs characterCode comparison

Benchmark created on


Description

When comparing basic string characters that fall int he ASCII range is it faster to use the string integer for comparisons or is it faster to use a string comparison.

Test runner

Ready to run.

Testing in
TestOps/sec
Char Code
var test = "(1+(2*3)+((8)/4))+1";

for (var i = 0; i < test.length; i++) {
	test[i].charCodeAt(0) === "(".charCodeAt(0)
}
ready
String
var test = "(1+(2*3)+((8)/4))+1";

for (var i = 0; i < test.length; i++) {
	test[i] === "("
}
ready

Revisions

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