Debunk method calls in loop conditions
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var my_array = [0,1,2,3,4,5,6,7,8,9];
function myMethod() {
return my_array.length;
};
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
"slow" |
|
pending… |
"fast" |
|
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 1: published by Raymond
- Revision 2: published
- Revision 6: published
- Revision 7: published
- Revision 8: published by Ger Hobbelt
- Revision 9: published
- Revision 10: published
1 comment
Putting
lengthandmethod()in a single test is a bad idea. See Ger's revision for more accurate results.