number to string (v19)

Revision 19 of this benchmark created by derry on


Preparation HTML

<script>
  var num = [], str;
  for (var i=0; i<1000; i++) num[i] = 1024*1024*1024*1024+i;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
String literal
for (i=0; i<1000; i++)
  str = "" + num[i] + "";
ready
String constructor
for (i=0; i<1000; i++)
   str = String(num[i]);
ready
toString
for (i=0; i<1000; i++)
    str = num[i].toString();
ready
new String
for (i=0; i<1000; i++)
    str = new String(num[i])
ready
simple string literal
for (i=0; i<1000; i++)
    str = '' + num[i];
ready
simple string literal const
for (i=0; i<1000; i++)
    str = '' + num[0];
ready

Revisions

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