math abs vs conditional
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
math_abs = Math.abs;
var a = Math.random();
if(Math.random()<0.5) a=-a;
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Native |
|
pending… |
Conditional inline |
|
pending… |
math_abs |
|
pending… |
Conditional if |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments