arr-map-filter-reduce
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var n = 10000,
arr = new Array(n)
drop = 0.1 // Proportion of numbers to drop
;
// Deterministic pseudo-random numbers to make sure
// arr is always generated the same way.
// http://stackoverflow.com/questions/521295/javascript-random-seeds
var seed = 1;
function random() {
var x = Math.sin(seed++) * 10000;
return x - Math.floor(x);
}
for (var i = n; i--;)
arr[i] = {
p: random() < drop ? null : i
};
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Test | Ops/sec | |
---|---|---|
3 loops
|
|
pending… |
1 loop
|
|
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.
- Revision 1: published G. Lathoud
- Revision 2: published G. Lathoud
- Revision 3: published G. Lathoud
- Revision 4: published G. Lathoud
- Revision 5: published
0 Comments