operator functions
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
function internalTestFunction() {
this.property += Math.random();
}
function externalTestFunction(object) {
object.property += Math.random();
}
function prototype_constructor() {
this.property = Math.random();
};
window.pp = prototype_constructor;
prototype_constructor.prototype = {
testFunction: internalTestFunction
};
function object_constructor() {
this.property = Math.random();
this.testFunction = internalTestFunction;
};
function external_constructor() {
this.property = Math.random();
}
var prototype_suit = [];
var object_suit = [];
var external_suit = [];
var n = 100;
while (n--) {
prototype_suit.push(new prototype_constructor);
object_suit.push(new object_constructor);
external_suit.push(new external_constructor);
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Prototype |
|
pending… |
Object |
|
pending… |
External |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments