string to int

Benchmark created by TestGuyManThing on


Description

Various ways of converting a string to an int

Setup

var a=3.1415;

Test runner

Ready to run.

Testing in
TestOps/sec
parseInt
if((parseInt(a,10))!==3){throw "Error";}
ready
bitwise |
if((a|0)!==3){throw "Error";}
ready
bitwise ~~
if((~~a)!==3){throw "Error";}
ready
bitwise >>
if((a>>0)!==3){throw "Error";}
ready
bitwise >>>
if((a>>>0)!==3){throw "Error";}
ready

Revisions

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

  • Revision 1: published by TestGuyManThing on