in array

Benchmark created on


Setup

function is_array(a)
{ try{
	if (Array.isArray(a)) return true;
} catch(e){} return false; }

function in_arr(i,kal)
{
	if(is_array(i))
	{
		for(var j=0;j<i.length;j++)
			for(var el in kal) if(i[j]===kal[el]) return true;
	}
	for(var el in kal) if(i===kal[el]) return true;
	return false;
}

function original(prop) {
	return !in_arr(prop, [
				"auth",
				"last_sync",
				"socket",
				"character",
				"last_upush",
				"push",
				"last",
				"last_u",
				"width",
				"height",
				"u",
				"user",
			])
}

function replacement(prop) {
	return ![
				"auth",
				"last_sync",
				"socket",
				"character",
				"last_upush",
				"push",
				"last",
				"last_u",
				"width",
				"height",
				"u",
				"user",
			].includes(prop)
}

Test runner

Ready to run.

Testing in
TestOps/sec
original
original('yes')
ready
replacement
replacement('yes')
ready
equality
if(original('yes') !== replacement('yes')) throw new Error('butts')
ready

Revisions

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