key access (v3)

Revision 3 of this benchmark created on


Setup

let LOC = "_btns"

let c = {
	_btns: [{name: 'test'}]
}


Test runner

Ready to run.

Testing in
TestOps/sec
prop from function scope
function t(){
	if(c._btns[0].name == 'test'){}
}

t()
ready
key from function scope
function u(){
	if(c[LOC][0].name == 'test'){}
}

u()
ready
prop
if(c._btns[0].name == 'test'){}
ready
key
if(c[LOC][0].name == 'test'){}
ready
double scope key
function u(c){
	function y(c){
		if(c[LOC][0].name == 'test'){}
	}
	y(c)
}

u(c)
ready
double scope prop
function u(c){
	function y(c){
		if(c._btns[0].name == 'test'){}
	}
	y(c)
}

u(c)
ready
best bet?
function t(c){
	if(c._btns[0].name == 'test'){}
}

t(c)
ready
better bet?
function t(c){
	let loc = '_btns'
	if(c[loc].name == 'test'){}
}

t(c)
ready
hmmmm perhaps
function t(loc){
	if(loc.name == 'test'){}
}

t(c._btns)
ready

Revisions

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