while vs for_in
JavaScript performance comparison
Info
test "while" and "for in" speed when applying to list, the array number is more than "http://jsperf.com/for-vs-for-in"
Preparation code
<script>
Benchmark.prototype.setup = function() {
var l1 = [2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 3, 4, 5, 6, 1, 2, 3, 4, 5, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 3, 4, 5, 6, 1, 2, 3, 4, 5, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 3, 4, 5, 6, 1, 2, 3, 4, 5, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1];
var sum = 0;
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
test "for in" |
|
pending… |
test while |
|
pending… |
test for |
|
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 54yuri
- Revision 2: published
- Revision 3: published by 54yuri
- Revision 4: published
- Revision 5: published
- Revision 6: published
- Revision 7: published
- Revision 8: published
- Revision 9: published
- Revision 10: published
- Revision 11: published
- Revision 12: published
- Revision 13: published
0 comments