Double Tilde vs. ParseInt (v8)

Revision 8 of this benchmark created by James Hartig on


Setup

var i = '1561565', j,
    superParseInt = function(a) {
            return ~~parseInt(a, 10);
        };

Test runner

Ready to run.

Testing in
TestOps/sec
Double Tilde
j = ~~i;
ready
ParseInt
j = parseInt(i, 10);
j = isNaN(j) ? 0 : j;
ready
Best of both worlds?
j = superParseInt(i);
ready
Slight change to parseInt
j = ~~parseInt(i, 10);
ready

Revisions

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