As Technical Director at QuasarApp Group, I'm passionate about creating procedural generated content for games. Recently, I noticed that the fast implementation of OpenSimplex2F was migrated from C to Rust, with the C version marked as deprecated. This raised a question: is the new Rust implementation as fast as its predecessor?
In this article, we'll perform a performance benchmark between the deprecated C implementation and the new Rust implementation. We'll also test the original C implementation separately to ensure there's no regression in speed.
The Need for Speed
As developers, we often face the challenge of balancing speed with maintainability. In mobile app development, every millisecond counts, especially when it comes to complex algorithms like OpenSimplex2F. This noise function is crucial for creating realistic terrain and environments in games. With this in mind, I decided to put the three implementations under scrutiny.
The Benchmark
To conduct the benchmark, I used an AMD Ryzen 5600X processor with -O2 compilation optimization level. I created a raw noise 2D on a large plane around 8K image for each implementation. The results are as follows:
- MarcoCiaramella C Impl 2D: 629 msec
- Deprecated C Impl 2D: 617 msec
- Rust Impl 2D: 892 msec
After the first iteration of optimizations, the situation improved slightly:
- MarcoCiaramella C Impl 2D: 623 msec
- Deprecated C Impl 2D: 617 msec
- Rust Impl 2D: 686 msec
The second iteration brought even better results:
- MarcoCiaramella C Impl 2D: 626 msec
- Deprecated C Impl 2D: 617 msec
- Rust Impl 2D: 602 msec
Conclusion
While Rust has made significant progress in terms of performance, the deprecated C implementation still holds a slight edge. However, it's essential to note that Rust is a relatively new addition to the OpenSimplex2F family, and further optimizations could lead to even better results.
As mobile app developers, we must prioritize speed and efficiency while maintaining code quality. By choosing the right implementation for our project, we can ensure a smoother experience for our users. In the world of mobile app development, every millisecond counts – and with OpenSimplex2F, we're one step closer to creating realistic and engaging experiences.
Target Keyword: mobile app development