Mojang / ore-ui

💎 Building blocks to construct game UIs using web tech.
https://react-facet.mojang.com/
MIT License
404 stars 19 forks source link

Optimizes looping Facet listeners #94

Closed pirelenito closed 8 months ago

pirelenito commented 1 year ago

Using the https://esbench.com/bench/6317fc2a6c89f600a5701bc9 in a JIT less environment, we confirmed this method to be the fastest to loop the listeners:

image

Although the difference is too small to be caught by our current automated benchmark tests.

When JIT is available, using an Array would be more performant, but given we are targeting game consoles as our main platform and they don't have JIT available, a Set with a forEach is the better option.

To test without JIT, I have used Chrome with the flag --js-flags="--jitless".

pirelenito commented 8 months ago

Closing as it will need further investigation and testing. Can be revisited later.