trnbdtybfg
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var slice = [].slice;
function f1(arr) {
return slice.call(arr)
}
function f2(arr) {
var obj=Object(arr),
len = obj.length>>>0,
rez= Array(len);
while (len--)if(len in obj)rez[len] = obj[len];
return rez
}
function f3(arr) {
var len = arr!=null?arr.length>>>0:0,
rez= Array(len);
while (len--)if(len in arr)rez[len] = arr[len];
return rez
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
f1 x 2 |
|
pending… |
f2 x 2 |
|
pending… |
f1 x 20 |
|
pending… |
f2 x 20 |
|
pending… |
f3 x 2 |
|
pending… |
f3 x 20 |
|
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:
- Revision 1: published
- Revision 2: published
- Revision 3: published
- Revision 4: published
- Revision 5: published
0 comments