cl vs pr
JavaScript performance comparison
Test case created
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Testing in unknown unknown
| Test |
Ops/sec |
Closure |
function Pixel(x, y) { this.x = x; this.y = y; this.getX = function() { return this.x; } this.getY = function() { return this.y; } this.setX = function(value) { this.x = value; } this.setY = function(value) { this.y = value; } }
function TestPerformance() { for (var i = 0; i < 20000; i++) { var x = new Pixel(i, i); } }
TestPerformance()
|
pending… |
Prototype |
// Prototype implementation function PixelP(x, y) { this.x = x; this.y = y; } PixelP.prototype.getX = function() { return this.x; } PixelP.prototype.getY = function() { return this.y; } PixelP.prototype.setX = function(value) { this.x = value; } PixelP.prototype.setY = function(value) { this.y = value; }
function TestPerformance() { for (var i = 0; i < 20000; i++) { var x = new PixelP(i, i); } }
TestPerformance()
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
Compare results of other browsers
0 comments