For Loop: Pre-Increment vs. Post-Increment (v7)

Revision 7 of this benchmark created on


Description

Just read about it today and here's a Test-case.

http://www.fairwaytech.com/2012/03/prefix-vs-postfix-increment-and-decrement-operators-in-c/

-- Added short versions of the for-loop

Setup

var tab = new Uint8Array(1000);

Test runner

Ready to run.

Testing in
TestOps/sec
Pre-increment
for (var i = 0; i < 1000; ++i) {
tab[i] = 0;
}
ready
Post-Increment
for (var i = 0; i < 1000; i++) {
tab[i] = 0;
}
ready
+=
for (var i = 0; i < 1000; i += 1) {
tab[i] = 0;
}
ready
short for i--
for (var i = 0; i < 1000;) {
tab[i++] = 0;
}
ready
short for --i
for (var i = 1000; --i;) {}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.