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

Revision 5 of this benchmark created by Rafał Matysiak on


Setup

var num = 5.7;

Test runner

Ready to run.

Testing in
TestOps/sec
String
var numFloor = +(""+num).split('.')[0];
ready
regex
var numFloor = +(""+num).match(/([0-9]+)\./)[0];
ready
Math.floor()
var numFloor = Math.floor(num);
ready
num << 0
var numFloor = num << 0;
ready
parseInt()
var numFloor = parseInt(num, 10);
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