If vs Cached (v5)

Revision 5 of this benchmark created on


Setup

const repeats = 1e9;
let flag = Math.random() > 0.5;

let counter = 0;

function branch(){
	if(flag)
		++counter;
	else
		--counter;
}

function cacheLE(){
	++counter;
}

function cacheBE(){
	--counter;
}

let cache = flag ? cacheLE : cacheBE;

Test runner

Ready to run.

Testing in
TestOps/sec
Branches
for(let i = 0; i < repeats; ++i)
	branch();
ready
Cached functions
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.