function or closurezz1
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
function Hi(x) {
this.x = x;
}
Hi.prototype.add = function(y) {
return this.x + y
}
var hiClosure = function(x) {
return {
x: x,
add: function(y) {
return this.x + y
}
}
}
var hi = new Hi(4);
var hi2 = hiClosure(4);
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
function |
|
pending… |
closure |
|
pending… |
function with creating |
|
pending… |
closure with creating |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments