distancemetrics

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var dist, x = [],
      y = [];
    for (var i = 0; i <= 10; ++i) {
      x[i] = Math.random() * 100;
      y[i] = Math.random() * 100;
    }
};
</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
e
for (var i = 0; i < 10; ++i) {
  var dx = x[i] - x[i + 1],
    dy = y[i] - y[i + 1];
  dist = Math.sqrt(dx * dx + dy * dy);
}
pending…
m
for (var i = 0; i < 10; ++i) {
  var dx = x[i] - x[i + 1],
    dy = y[i] - y[i + 1];
  dist = (dx < 0 ? -dx : dx) + (dy < 0 ? -dy : dy);
}
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