Loops
JavaScript performance comparison
Preparation code
<script>
var arr = [0.10682249767705798, 0.14486907375976443, 0.6462927060201764, 0.6292556400876492, 0.8099745651707053, 0.026500273030251265, 0.7382857352495193, 0.5344766841735691, 0.22327085630968213, 0.24449701607227325, 0.7350677938666195, 0.6318817269057035, 0.4497333753388375, 0.13978702807798982, 0.9937113982159644, 0.10464582103304565, 0.17325501330196857, 0.8751101894304156, 0.9214370618574321, 0.9315629999618977, 0.9574287028517574, 0.6804302292875946, 0.9841849545482546, 0.40987069346010685, 0.9036554736085236, 0.9259901174809784, 0.0500990585424006, 0.46978900488466024, 0.6059614983387291, 0.8904959128703922, 0.7805201290175319, 0.4566794545389712, 0.8901236969977617, 0.15785527019761503, 0.13910270063206553, 0.4444686050992459, 0.24656269908882678, 0.013628697721287608, 0.8823351296596229, 0.6517225778661668, 0.8656179755926132, 0.319807083113119, 0.9416418434120715, 0.4895877211820334, 0.7494010012596846, 0.46209143311716616, 0.12883754167705774, 0.9753151724580675, 0.35535205458290875, 0.3615832484792918, 0.16555020376108587, 0.14845219417475164, 0.6793364111799747, 0.9124694655183703, 0.12904104171320796, 0.5627066746819764, 0.4686171298380941, 0.45925762108527124, 0.047439801041036844, 0.05272998288273811, 0.9997752527706325, 0.5681999593507499, 0.03658395493403077, 0.473449117038399, 0.41875638091005385, 0.9229928401764482, 0.21255105710588396, 0.8998285585548729, 0.7891316991299391, 0.6155658783391118, 0.8909062976017594, 0.01669530081562698, 0.6303473026491702, 0.07017915393225849, 0.661483193282038, 0.8687872167211026, 0.09445122606121004, 0.7184298713691533, 0.675882583251223, 0.7469109978992492, 0.6185253721196204, 0.3029119106940925, 0.3411432655993849, 0.8031496377661824, 0.7103048702701926, 0.409196141641587, 0.9286595492158085, 0.48906754329800606, 0.5625964961946011, 0.72299401788041, 0.606512616854161, 0.3410133202560246, 0.8974989776033908, 0.5539657713379711, 0.6715649494435638, 0.013221136294305325, 0.8913248141761869, 0.9076709996443242, 0.12053222325630486, 0.3550975953694433];
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
while loop that imitates a for loop |
|
pending… |
while loop that imitates a for loop, caching the length |
|
pending… |
Reverse while loop |
|
pending… |
Reverse do … while loop |
|
pending… |
Reverse for loop |
|
pending… |
Old ’n’ busted for loop |
|
pending… |
Old ’n’ busted for loop, caching the length |
|
pending… |
Cool guy loop |
|
pending… |
Cool guy loop, caching the length |
|
pending… |
Native Array#forEach implementation |
|
pending… |
Native Array#forEach implementation with named function |
|
pending… |
Unrolled loop |
|
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 Mathias Bynens and last updated
- Revision 2: published
- Revision 4: published by Thomas Aylott and last updated
- Revision 6: published by WebReflection and last updated
- Revision 9: published by JFSIII and last updated
- Revision 10: published by Thomas Aylott
- Revision 17: published
- Revision 18: published by Lockal
- Revision 19: published by Lockal
- Revision 20: published
- Revision 21: published
- Revision 22: published
- Revision 23: published by Mike Lee
- Revision 24: published
- Revision 26: published by match vs split
- Revision 27: published by John-David Dalton and last updated
- Revision 29: published by Lucas Cepeda
- Revision 30: published
- Revision 31: published
- Revision 32: published
- Revision 33: published
- Revision 34: published by FrancescoMM
- Revision 35: published by Elijah Manor
- Revision 38: published by D. S. Schneider
- Revision 39: published
- Revision 40: published
- Revision 41: published by D. S. Schneider
- Revision 42: published
- Revision 43: published
- Revision 44: published
- Revision 46: published
- Revision 47: published
- Revision 48: published by Justin Bangerter
- Revision 49: published by Conor Malone
- Revision 50: published by Conor Malone
- Revision 51: published by Tri
- Revision 52: published by Raul
- Revision 53: published
- Revision 54: published
- Revision 55: published
- Revision 56: published
- Revision 58: published
- Revision 59: published
- Revision 60: published
- Revision 61: published
- Revision 62: published
- Revision 63: published
- Revision 64: published
- Revision 66: published
- Revision 67: published
- Revision 68: published
- Revision 69: published
- Revision 70: published
- Revision 71: published
- Revision 72: published
- Revision 73: published by wfreytag
- Revision 75: published
- Revision 76: published
- Revision 77: published
- Revision 78: published
- Revision 79: published
- Revision 80: published
- Revision 81: published by eTagTechnologies.Inc
- Revision 82: published by JeanHuguesRobert
- Revision 83: published
- Revision 84: published by Simo
- Revision 85: published
- Revision 86: published by Matt
0 comments