hecs icon indicating copy to clipboard operation
hecs copied to clipboard

Add performance benchmarking around systems loop

Open canadaduane opened this issue 5 years ago • 2 comments

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?

canadaduane avatar Nov 19 '20 02:11 canadaduane

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 })

ashconnell avatar Nov 19 '20 02:11 ashconnell

Good point. I like your proposed solution as well.

canadaduane avatar Nov 19 '20 02:11 canadaduane