Angular foreach vs Underscore foreach vs native For Loop vs reverse native for loop
JavaScript performance comparison
Preparation code
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js"></script>
<script src="http://underscorejs.org/underscore-min.js"></script>
<script>
Benchmark.prototype.setup = function() {
var arr = {};
var sum = 0;
for (var i = 0; i < 100000; i++) {
arr['i' + i] = i;
}
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Test | Ops/sec | |
---|---|---|
angular foreach
|
|
pending… |
underscore foreach
|
|
pending… |
for loop
|
|
pending… |
for loop reverse
|
|
pending… |
for loop with caching
|
|
pending… |
for ... in
|
|
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.
- Revision 1: published
- Revision 2: published
- Revision 3: published
- Revision 4: published Alexey
- Revision 5: published James Daily
- Revision 6: published James Daily
- Revision 7: published James Daily
- Revision 8: published
- Revision 9: published viktor
- Revision 10: published
- Revision 12: published
- Revision 13: published
- Revision 18: published
- Revision 19: published
- Revision 20: published
- Revision 21: published
- Revision 23: published test1212312
- Revision 24: published sunsean
- Revision 25: published danmasta
- Revision 26: published
- Revision 27: published Jamie
- Revision 29: published
- Revision 30: published Luscus
- Revision 31: published etc
- Revision 32: published Jimmy Jansen
- Revision 33: published Gerry
- Revision 34: published Mayank
- Revision 35: published Mike
- Revision 38: published Alejandro Rangel
- Revision 39: published belikemike
- Revision 41: published
- Revision 42: published Erik
- Revision 43: published Erik
- Revision 45: published
- Revision 46: published
- Revision 47: published
- Revision 48: published
- Revision 49: published
- Revision 50: published
- Revision 51: published
- Revision 52: published
- Revision 53: published
- Revision 54: published
- Revision 56: published
- Revision 60: published
0 Comments