Run details:
Mozilla/5.0 (iPhone; CPU iPhone OS 17_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/122.0.6261.62 Mobile/15E148 Safari/604.1
Chrome Mobile iOS 122
iOS 17.3
Mobile
one year ago
Test name Executions per second
Number (with string integer) 5931248.0 Ops/sec
Unary + (with string integer) 8227985.0 Ops/sec
parseInt (with string integer) 5868448.5 Ops/sec
Number (with string float) 5269336.0 Ops/sec
Unary + (with string float) 7012829.5 Ops/sec
parseInt (with string float) 5456702.0 Ops/sec
Number (with integer) 5364293.0 Ops/sec
Unary + (with integer) 6772040.5 Ops/sec
parseInt (with integer) 7006745.5 Ops/sec
Number (with float) 8369837.5 Ops/sec
Unary + (with float) 18604116.0 Ops/sec
parseInt (with float) 9866893.0 Ops/sec
Number (with NaN) 17893268.0 Ops/sec
Unary + (with NaN) 192085632.0 Ops/sec
parseInt (with NaN) 19079310.0 Ops/sec
Tests:
  • Number (with string integer)

    AخA
     
    var numberStrInt = Number(Math.floor(1000 * Math.random()).toString());
  • Unary + (with string integer)

     
    var unaryStrInt = +Math.floor(1000 * Math.random()).toString();
  • parseInt (with string integer)

     
    var parseStrInt = parseInt(Math.floor(1000 * Math.random()).toString(), 10);
  • Number (with string float)

     
    var numberStrFloat = Number((1000 * Math.random()).toString());
  • Unary + (with string float)

     
    var unaryStrFloat = +(1000 * Math.random()).toString();
  • parseInt (with string float)

     
    var parseStrFloat = parseInt((1000 * Math.random()).toString(), 10);
  • Number (with integer)

     
    var numberNumInt = Number(Math.floor(1000 * Math.random()));
  • Unary + (with integer)

     
    var unaryNumInt = +Math.floor(1000 * Math.random());
  • parseInt (with integer)

     
    var parseNumInt = parseInt(Math.floor(1000 * Math.random()), 10);
  • Number (with float)

     
    var numberNumFloat = Number(1000 * Math.random());
  • Unary + (with float)

     
    var unaryNumFloat = +(1000 * Math.random());
  • parseInt (with float)

     
    var parseNumFloat = parseInt((1000 * Math.random()), 10);
  • Number (with NaN)

     
    var numberNaN = Number("hello");
  • Unary + (with NaN)

     
    var unaryNaN = +("hello");
  • parseInt (with NaN)

     
    var parseNaN = parseInt("hello", 10);