property static vs symbol access speed (v3)

Revision 3 of this benchmark created on


Setup

const aSymbol = Symbol.for('test');

function getFNStatic(){
	function FNStatic(){}
	FNStatic.aStatic = Math.random();
	return FNStatic;
}

function getFNSymbol(){
	function FNSymbol(){}
	FNSymbol[aSymbol] = Math.random();
	return FNSymbol;
}

function getFNNumber(){
	function FNNumber(){}
	FNNumber[0] = Math.random();
	return FNNumber;
}

let result = 0;
const iter = 100;

Test runner

Ready to run.

Testing in
TestOps/sec
static
result = 0;
const FNStatic = getFNStatic();
for(let i=0;i<iter;i++){
	result += FNStatic.aStatic;
}
ready
symbol
result = 0;
const FNSymbol = getFNSymbol();
for(let i=0;i<iter;i++){
	result += FNSymbol[aSymbol];
}
ready
number
result = 0;
const FNNumber = getFNNumber();
for(let i=0;i<iter;i++){
	result += FNNumber[0];
}
ready

Revisions

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