string property vs array property lookup

Benchmark created on


Setup

let entity = {}
entity.type = "actor"
entity.tags = ["npc", "food", "actor", "edible", "a", "b", "c", "d", "e"]
let i = 0;

Test runner

Ready to run.

Testing in
TestOps/sec
String property lookup
if (entity.type == "actor") {
	i++
}
ready
Array property lookup
if (entity.tags.includes("actor")) {
	i++
}
ready

Revisions

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