test parseInt() and Math.floor() (v10)

Revision 10 of this benchmark created by Arkadiusz Sygulski on


Setup

var num = Math.random();
  var five = 5;

Test runner

Ready to run.

Testing in
TestOps/sec
:3
var numFloor = five;
ready
num << 0
var numFloor = num << 0;
ready
String
var numFloor = +(""+num).split('.')[0];
ready
Math.floor()
var numFloor = Math.floor(num);
ready
parseInt()
var numFloor = parseInt(num, 10);
ready
regex
var numFloor = +(""+num).match(/([0-9]+)\./)[0];
ready

Revisions

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

  • Revision 1: published by Dave on
  • Revision 2: published on
  • Revision 3: published by Arkadiusz Sygulski on
  • Revision 4: published by Arkadiusz Sygulski on
  • Revision 5: published by Rafał Matysiak on
  • Revision 6: published by Kuba on
  • Revision 8: published by Rafał Matysiak on
  • Revision 9: published by Rafał Matysiak on
  • Revision 10: published by Arkadiusz Sygulski on
  • Revision 12: published by Slim GAIGI on
  • Revision 13: published by Slim GAIGI on
  • Revision 14: published by auffret on
  • Revision 15: published by auffret on
  • Revision 16: published by auffret on
  • Revision 17: published by auffret on
  • Revision 20: published by Yurij Krot on
  • Revision 21: published by Yurij Krot on