Object comparison vs string comparison. (v2)

Revision 2 of this benchmark created on


Setup

const TYPE_THING = {name:"RECORD"};
const obj1 = TYPE_THING;
const obj2 = TYPE_THING;
const TEST_CASES = new Array(10000).fill(1)

const compareString = (comp1, comp2) => {
	return comp1.name === comp2.name
}
const compareObjRef = (comp1, comp2) => {
	return comp1 === comp2
}

Test runner

Ready to run.

Testing in
TestOps/sec
comparison to string
const results = TEST_CASES.map(()=> compareString(obj1,obj2))
ready
comparison to object ref
const results = TEST_CASES.map(()=> compareObjRef(obj1,obj2))
ready

Revisions

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