parseFloat .toFixed vs. Math.round (v32)

Revision 32 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Math.round
var test = [Math.random() * 10, Math.random() * 20, Math.random() * 30, Math.random() * 40, Math.random() * 50];

for (var i = 0; i < test.length; i++) {
  Math.round(test[i] * 100) / 100;
}
ready
parseFloat .toFixed
var test = [Math.random() * 10, Math.random() * 20, Math.random() * 30, Math.random() * 40, Math.random() * 50];

for (var i = 0; i < test.length; i++) {
  parseFloat(test[i].toFixed(2));
}
ready

Revisions

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