Number() vs parseInt() vs plus vs bitwise (v124)

Revision 124 of this benchmark created on


Setup

var valueString = "" + new Date().valueOf();
  
  console.log('Number', Number(valueString));
  console.log('parseInt', parseInt(valueString));
  console.log('parseInt, 10', parseInt(valueString, 10));
  console.log('plus', +valueString);
  console.log('bitwise', valueString >> 0);
  console.log('multiplie', valueString * 1)
  console.log('not not', ~~valueString)
  console.log('pipe 0', valueString | 0)

Test runner

Ready to run.

Testing in
TestOps/sec
parseInt
parseInt(valueString);
ready
pipe 0
valueString | 0;
ready
multiplie
valueString * 1;
ready
Number
Number(valueString);
ready
plus
+valueString;
ready
bitwise
valueString >> 0;
ready
not not
~~valueString;
ready
parseInt, 10
parseInt(valueString, 10);
ready

Revisions

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