performance of parseInt() (v34)

Revision 34 of this benchmark created by Tri on


Description

Side note on big numbers (32-bit or bigger)

The result of binary operations are signed 32-bit numbers. Standard ECMA-262 5.1

  • 11.7 Binary shift operators
  • 11.10 Binary bitwise operators

Setup

var str="4";

Test runner

Ready to run.

Testing in
TestOps/sec
parseInt(x)
var i=parseInt(str)
ready
parseInt(x, 10)
var i=parseInt(str, 10)
ready
+x
var i=+str
ready
~~x
var i=~~str
ready
parseFloat(x)
var i=parseFloat(str)
ready
Number(x)
var i=Number('4')
ready
Math.ceil(x)
var i=Math.ceil(str)
ready
Math.round()
var i=Math.round(str)
ready
x >> 0
var i=str >> 0
ready
x >>> 0
var i=str >>> 0
ready
x + 0
var i=str + 0
ready
x * 1
var i=str * 1
ready
Math.floor
var i=Math.floor(str)
ready

Revisions

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