Mojang / ore-ui

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

Optimizes looping Facet listeners #94

Closed pirelenito closed 9 months ago

pirelenito commented 2 years 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 9 months ago

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