anonymouse function optimisation
JavaScript performance comparison
Preparation code
<script type="text/javascript">
var aaa = ( function () {
var arr = [],
index = 0,
length = 1000;
for ( ; index < length; index++ ) {
arr.push( index );
}
return function aaa ( loc ) {
return arr.indexOf( loc );
};
})(),
bbb = function bbb ( loc ) {
var arr = [],
index = 0,
length = 1000;
for ( ; index < length; index++ ) {
arr.push( index );
}
return arr.indexOf( loc );
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
cached |
|
pending… |
not cached |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments