third party each loops
JavaScript performance comparison
Info
Tests the performance of various each loops
Preparation code
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
//gaffa.js fastEach
Array.prototype.fastEach = function (callback) {
for (var i = 0; i < this.length; i++) {
if(callback(this[i], i, this)) break;
}
};
//gaffa.js fastEach with no convenience params
Array.prototype.superfastEach = function (callback) {
var length = this.length;
for (var i = 0; i < length; i++) {
callback(this[i]);
}
};
//some big array
var data = [];
//useless data
for(var i = 0; i < 10000; i++){
data[i] = 1;
}
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
native each |
|
pending… |
gaffa fastEach |
|
pending… |
underscore each |
|
pending… |
normal for |
|
pending… |
superfastEach |
|
pending… |
jquery each |
|
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 Kory Nunn
- Revision 2: published
- Revision 3: published by Yannick Albert
0 comments