point array vs point object
JavaScript performance comparison
Preparation code
<script>
var point_o = function(x,y) {
this.X=x;
this.Y=y;
}
var point_a = function(x,y) {
return [x,y];
}
var point_o_arr = [];
var point_a_arr = [];
var x_arr = [];
var y_arr = [];
var x,y;
var len=100;
for(var i=0;i<len;i++)
{
x = Math.random()*10000;
y = Math.random()*10000;
point_o_arr.push(new point_o(x,y));
point_a_arr.push(point_a(x,y));
x_arr.push(x);
y_arr.push(y);
}
//console.log(JSON.stringify(point_o_arr));
//console.log(JSON.stringify(point_a_arr));
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
R object |
|
pending… |
R array |
|
pending… |
W object |
|
pending… |
W array |
|
pending… |
RW object |
|
pending… |
RW array |
|
pending… |
// R xy-array |
|
pending… |
W xy-array |
|
pending… |
RW xy-array |
|
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 Timo
- Revision 2: published by Timo
0 comments