Attempts at Constant Propagation (v7)

Revision 7 of this benchmark created on


Setup

count = 0;

function branchy(x) {
	if (x == 1) {
		count |= 2;
	} else if (x == 2) {
		count |= 3;
	} else if (x == 3) {
		count |= 15;
	} else if (x == 4) {
		count |= 18;
	} else if (x == 5) {
		count |= 21;
	}
}

arr = new Int32Array(1);
arr[0] = 5;

closure = function(val) {
	return function() { branchy (val); }
}(arr[0]);

closureWithConst = function(val) {
	const v = val;
	return function() { branchy (v); }
}(arr[0]);

Test runner

Ready to run.

Testing in
TestOps/sec
Direct Call
branchy(arr[0]);
ready
Simple Closure
closure();
ready
Closure with Const
closureWithConst();
ready

Revisions

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