For vs Let in loops

Benchmark created on


Description

Testing fors and lets/vars (I don't know why I'm doing it and what I'm expecting... x_x)

Setup

function doStuff(i){ i*=2 }

Test runner

Ready to run.

Testing in
TestOps/sec
for-var-let inline
for(var i = 0; i<=1e9; i+=1){
	let val = i * 2;
	doStuff(val);
}
ready
for-var-let outside
var i;
let val;
for(i = 0; i<=1e9; i+=1){
	val = i * 2;
	doStuff(val);
}
ready
for-let-var inline
for(let i = 0; i<=1e9; i+=1){
	var val = i * 2;
	doStuff(val);
}
ready
for-let-var outside
let i;
var val;
for(i = 0; i<=1e9; i+=1){
	val = i * 2;
	doStuff(val);
}
ready
for-var-var inline
for(var i = 0; i<=1e9; i+=1){
	var val = i * 2;
	doStuff(val);
}
ready
for-var-var outside
var i, val;
for(i = 0; i<=1e9; i+=1){
	val = i * 2;
	doStuff(val);
}
ready
for-let-let inline
for(let i = 0; i<=1e9; i+=1){
	let val = i * 2;
	doStuff(val);
}
ready
for-let-let outside
let i, val;
for(i = 0; i<=1e9; i+=1){
	val = i * 2;
	doStuff(val);
}
ready

Revisions

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