For loop (v3)

Revision 3 of this benchmark created on


Setup

A = 0;
function loop() {
	++A
}

function *iter(a, b) {
	for(let i = a; __islower__(i, b); i=__incr__(i) ) {
		loop(); //
		yield i
	}
}

function __islower__(a,b) {
	return a < b
}
function __incr__(a) {
	return ++a
}

Test runner

Ready to run.

Testing in
TestOps/sec
Brython
incr = 0n;
for(let i of iter(0n,1000n) )
    incr += i
    

console.log(incr, A);
ready
Proposed
incr = 0n;
for(let i=0n; __islower__(i, 1000n); i=__incr__(i) ) {
	loop();
    incr += i
}
    

console.log(incr, A);
ready
Cheat
incr = 0;
for(let i=0; i < 1000; ++i ) {
	loop();
    incr += i
}
    

console.log(incr, A);
ready

Revisions

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