Loop Reverse
JavaScript performance comparison
Info
what is the best way to loop? Forwards? Backwards?
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
Benchmark.prototype.setup = function() {
var list = ['radiohead', 'jeff', 'sigur ros', 'hammock', 'eluvium', 'mono', 'mogwai', 'olafur', 'hello destiny', 'cool things', 'between the buried and me', 'this will destroy you'];
var doStuff = function(item) {
var words = item.split(' ');
return words;
};
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
each |
|
pending… |
for++ |
|
pending… |
for-- |
|
pending… |
while |
|
pending… |
for-- 2 |
|
pending… |
for -- 3 |
|
pending… |
for -- 4 |
|
pending… |
for -- 5 |
|
pending… |
6 |
|
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 Jeff
- Revision 2: published
- Revision 3: published
- Revision 4: published
- Revision 5: published
- Revision 6: published
- Revision 7: published
0 comments