parseFloat .toFixed vs. Math.round (v18)

Revision 18 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Math.round
var test = [1.2345345, 2.345656745, 3.45675456654, 4.56785467, 5.67894567];
var command = 'M';
var string = '';

for (var i = 0; i < test.length; i++) {
  string = command + ' ' + Math.floor(test[i] * 1000) / 1000;
}
ready
parseFloat .toFixed
var test = [1.2345345, 2.345656745, 3.45675456654, 4.56785467, 5.67894567];
var command = 'M';
var string = '';

for (var i = 0; i < test.length; i++) {
  string = command + ' ' + test[i].toFixed(3);
}
ready

Revisions

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