W icon indicating copy to clipboard operation
W copied to clipboard

Performance improvement in render method

Open Lukenickerson opened this issue 10 months ago • 0 comments

While working on a game with a larger number of vertices, I found there was a performance bottleneck that was slowing down the rendering. When I investigated in the Chrome developer tools, I saw that toString was taking a lot of processing. I narrowed it down to this line: https://github.com/xem/W/blob/gh-pages/w.js#L337 For some reason when instantiating a DOMMatrix this way, there's some kind of implicit string conversion. (No idea why!❓)

Here was the change that improved the performance: https://github.com/morph-games/ring-rescue/commit/2822a62eda475461b4ed1322d9afcf50c30316ab#diff-9b7c0300e9f9c7a72e91a5f2890bd540663ae785b5c582a7b3ae15fac823bd6eR379

I can make a PR for this.

FWIW - The next bottleneck seems to be toFloat32Array, but I don't know if we can get around that without reimplementing some matrix math, which would take a lot of bytes.

Lukenickerson avatar Apr 26 '24 14:04 Lukenickerson