Array vs hex vs number (v3)

Revision 3 of this benchmark created on


Setup

function printError(y) {
	throw new Error('Outbound at', y);
}

function assign(x, y){
	if(y > N)
	     printError(y);
	     
	//DO STUFF
}
function assugn(y, x){
	if(y > N)
	     printError(y);
	     
	//DO STUFF
}
const N = 10000

Test runner

Ready to run.

Testing in
TestOps/sec
array
for(var i=0;i<N;i++){
	assign(i, [1, 2, 3])
}
ready
hex
for(var i=0;i<N;i++){
	assign(i, 0x13A)
}
ready
number
for(var i=0;i<N;i++){
	assign(i, 314)
}
ready
Invert hex
for(var i=0;i<N;i++){
	assugn(0x13A, i)
}
ready
Invert num
for(var i=0;i<N;i++){
	assugn(314, i)
}
ready

Revisions

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