Nested Named Functions compared to Module Pattern without last module pattern
JavaScript performance comparison
Info
Investigating the performance hit caused by nested functions.
Preparation code
<script>
Benchmark.prototype.setup = function() {
var Closure = (function() {
var store;
function inner(a) {
store = a;
};
return {
Nested: function(a) {
function inner(a) {
store = a;
};
inner(a);
},
Unnested: function(a) {
inner(a)
}
}
})();
var flat;
function Nested(a) {
function inner(a) {
flat = a;
};
inner(a);
};
function Unnested(a) {
inner(a);
}
function inner(a) {
flat = a;
};
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Nested inside Closure |
|
pending… |
Unnested inside Closure |
|
pending… |
Nested |
|
pending… |
Unnested |
|
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 3: published by gdsf
- Revision 4: published
- Revision 5: published by gdsf
- Revision 6: published
- Revision 7: published
- Revision 9: published
- Revision 10: published
- Revision 13: published
- Revision 14: published
- Revision 15: published
- Revision 16: published
- Revision 17: published
- Revision 18: published
- Revision 19: published
- Revision 20: published
- Revision 21: published
- Revision 22: published
- Revision 23: published
- Revision 24: published by max jooher
0 comments