parseFloat .toFixed vs. Math.round

JavaScript performance comparison

Test case created

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Math.round
var test = [1.2345, 2.3456, 3.4567, 4.5678, 5.6789];

for (var i = 0; i < test.length; i++) {
  Math.round(test[i] * 100) / 100;
}
pending…
parseFloat .toFixed
var test = [1.2345, 2.3456, 3.4567, 4.5678, 5.6789];

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

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

1 comment

Imran commented :

Thanks a lot for wonderful article. It has helped me a lot in improving performance of my assignment.

Thanks

Add a comment