for vs forEach vs for-of
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
let values = Array.from({length: 10000}, (v, k) => k+1);
let sum = 0;
let add = function(x) {
sum += x;
}
};
Benchmark.prototype.teardown = function() {
sum = 0;
values = [];
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Test | Ops/sec | |
---|---|---|
for-of-callback
|
|
pending… |
forEach
|
|
pending… |
forEach-callback
|
|
pending… |
for
|
|
pending… |
for-of
|
|
pending… |
for-callback
|
|
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 Azlond
- Revision 2: published Jan Kaiser
- Revision 3: published Jan Kaiser
- Revision 4: published Jan Kaiser
- Revision 5: published Jan Kaiser
- Revision 6: published Lodder
- Revision 570: published
- Revision 574: published Orokon
- Revision 575: published Orokon
- Revision 576: published Mateus Ventura
- Revision 577: published Mateus Ventura
- Revision 578: published Mateus Ventura
- Revision 579: published
- Revision 580: published Nguyen Cao Nhat Linh
- Revision 581: published Artur Kulig
- Revision 582: published
- Revision 583: published Benjamin DANIEL
- Revision 584: published Benjamin DANIEL
- Revision 585: published Benjamin DANIEL
- Revision 586: published Benjamin DANIEL
- Revision 587: published Benjamin DANIEL
- Revision 588: published Andrey Bartashevitch
- Revision 589: published Andrey Bartashevitch
- Revision 590: published Ben Fortune
- Revision 591: published Ben Fortune
- Revision 592: published Adrian Barsan
- Revision 593: published Adrian Barsan
- Revision 594: published Nickolay Platonov
- Revision 595: published Nickolay Platonov
- Revision 596: published Nickolay Platonov
- Revision 597: published Cristian Trifan
- Revision 598: published Jermaine McFarlane
- Revision 599: published meteorlxy
- Revision 600: published Maksym Pushkin
- Revision 601: published Maksym Pushkin
- Revision 602: published
- Revision 603: published Yoan Pratama Putra
- Revision 604: published Andrii
- Revision 605: published Andrii
- Revision 606: published Andrii
- Revision 607: published Jonah
0 Comments