hashmap vs class

Benchmark created on


Setup

class Test {
	static accessStatic = 10;
	constructor(){
		this.accessThis = 20;
	}
}
const test = new Test();

const accessMap = function(){};
const hashMap = new Map();
hashMap.set(accessMap, 10);

let result = 0;

Test runner

Ready to run.

Testing in
TestOps/sec
Class static
result = 0;
for(let i=0;i<1000;i++){
result += test.accessStatic;
}
ready
Class this
result = 0;
for(let i=0;i<1000;i++){
result += test.accessThis;
}
ready
hashmap
result = 0;
for(let i=0;i<1000;i++){
result += hashMap.get(accessMap);
}
ready

Revisions

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