parse or no parse sort

JavaScript performance comparison

Test case created by Raymond

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var strings = ['1.02', '1.01', '1.001'];
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
no parseFloat
return strings.sort(function(a, b) {
  return a > b ? 1 : a < b ? -1 : 0;
});
pending…
parseFloat
return strings.sort(function(a, b) {
  a = parseFloat(a);
  b = parseFloat(b);
  return a > b ? 1 : a < b ? -1 : 0;
});
pending…

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

Compare results of other browsers

0 comments

Add a comment