Measuring performance with a browser
The first step in debugging performance is answering the question, Do you have a performance problem? Too many developers, especially game developers, worry too early about performance and introduce complex code for a performance gain that just isn't there.
For example, do you know why so much of this code uses i16
and f16
? Well, when I was going back to school a few years ago, I took a game optimization class in C++, where our final project needed to optimize a particle system. The biggest performance gains were to convert 32-bit integers into 16-bit integers. As my professor would say, "We got to the moon on 16-bit!" So, when I was writing this code, I internalized the lesson and made the variables 16-bit unless they were being sent to JavaScript, where everything is 32-bit anyway. Well, allow me to quote directly from the WebAssembly specification (found at https://webassembly.github.io/spec/core/syntax/types.html):