performance of parseInt() (v23)

Revision 23 of this benchmark created on


Description

Seeing what happens when it's fed a number (as is often the case in Box2D)

Setup

var someFloat = 999.99;
    var someInt = 999;

Test runner

Ready to run.

Testing in
TestOps/sec
parseInt(x)
var result;

result = parseInt(someFloat);
result = parseInt(someInt);
ready
parseInt(x, 10)
var result;

result = parseInt(someFloat, 10);
result = parseInt(someInt, 10);
ready
~~x
var result;

result = ~~someFloat;
result = ~~someInt;
ready
Math.floor(x)
var result;

result = Math.floor(someFloat);
result = Math.floor(someInt);
ready
Math.ceil(x)
var result;

result = Math.ceil(someFloat);
result = Math.ceil(someInt);
ready
Math.round()
var result;

result = Math.round(someFloat);
result = Math.round(someInt);
ready
x | 0
var result;

result = someFloat | 0;
result = someInt | 0;
ready
parseFloat(x)
var result;

result = parseFloat(someFloat);
result = parseFloat(someInt);
ready

Revisions

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