If vs Cached (v2)

Revision 2 of this benchmark created on


Setup

const repeats = 1e6;

Test runner

Ready to run.

Testing in
TestOps/sec
Branches
let flag = Math.random() > 0.5;
let counter = 0;
function branch(){
	if(flag)
		++counter;
	else
		--counter;
}


for(let i = 0; i < repeats ; ++i){
	branch();
}
ready
Cached functions
let counter = 0;
let flag = Math.random() > 0.5;

function cacheLE(){
	++counter;
}

function cacheBE(){
	--counter;
}

let cache = flag ? cacheLE : cacheBE;

for(let i = 0; i < repeats ; ++i){
	cache();
}
ready

Revisions

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