hecs
hecs copied to clipboard
Add performance benchmarking around systems loop
I added this to the SystemManager so that I could measure performance of each system individually:
update(delta) {
for (let i = 0; i < this.systems.length; i++) {
this.tick++
const system = this.systems[i]
const before = performance.now()
if (system.active) system.update(delta)
system.performance = performance.now() - before
}
}
Thoughts on adding it to core HECS?
This won't work in Node.js as you need to do this instead:
import { performance } from 'perf_hooks'
performance.now()
The only way around it I can think of is to provide this when creating the word, eg new World({ getTime: performance.now })
Good point. I like your proposed solution as well.