JavaScript Array Copy Comparison
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
Object.deepCopy = function(obj) {
if (typeof obj !== "object") return obj;
var newObj = (obj instanceof Array) ? [] : {};
for (i in obj) {
if (obj[i] && typeof obj[i] == "object") newObj[i] = Object.clone(obj[i]);
else newObj[i] = obj[i];
}
return newObj;
};
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Copy by slice |
|
pending… |
Copy by splice |
|
pending… |
Copy by concat |
|
pending… |
Copy by stringify & eval |
|
pending… |
Copy by iterator |
|
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 by JiangXiaoQiang
- Revision 2: published by Luis Cantero
0 comments