Double Tilde vs. ParseInt (v20)

Revision 20 of this benchmark created on


Setup

var i = '1561565', j = 0,
    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
Including true
j = i === true ? 1 : ~~parseInt(i, 10);
ready
Slight change to parseInt
j = ~~parseInt(i, 10);
ready
Or Zero
j = 0 | i;
ready

Revisions

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