String literal vs Object (v6)

Revision 6 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Strring Literal (v1)
var s = '0123456789';
for (var i = 0; i < s.length; i++) {
  s.charAt(i);
}
ready
String Literal (v2)
var s = '0123456789', ii = s.length;
for (var i = 0; i < ii; i++) {
  s.charAt(i);
}
ready
String Literal (v3)
var s = '0123456789';
for (var i = 0, ii = s.length; i < ii; i++) {
  s.charAt(i);
}
ready
String Literal from Object (v1)
var s = String('0123456789');
for (var i = 0; i < s.length; i++) {
  s.charAt(i);
}
ready
String Literal from Object (v2)
var s = String('0123456789'), ii = s.length;
for (var i = 0; i < ii; i++) {
  s.charAt(i);
}
ready
String Literal from Object (v3)
var s = String('0123456789');
for (var i = 0, ii = s.length; i < ii; i++) {
  s.charAt(i);
}
ready
String array
var s = '0123456789',a;
for (var i = 0; i < s.length; i++) {
a=  s[i];
}
ready

Revisions

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