Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Notes on Performance

Fast and snappy games delight users and run well on low end devices.

Algorithms and Data Structures (DSA)

Computer scientists spend their lives inventing faster ways to solve problems. Choosing the right algorithms and data structures can be the difference between your code finishing in a few millseconds vs a billion years. DSA improves asymptotic complexity.

We’ll go through a simple example in the next chapter. Strive to choose the best algorithms and data structures. Most often these are inbuilt in our language. You just have to recognize and call the appropriate procedures.

Micro optimization

We will walk through some techniques of optimizing code like choosing compact bit representations of data, CPU level parallelism, multithreading etc.

Micro optimization increases code complexity. Keep code as simple as possible and use it sparingly when parts of your game are too slow. In my experience, if you use DSA properly and utilize data driven design principles, you won’t need micro optimizations.

Counting in Billions

It’s quite useful to maintain a mental model of computation limits of modern computers. Modern CPUs run at clock speeds in Ghz. This translates to approximately a billion simple operations (like addition of numbers) per second.

Odin is fast. If you are coding in other languages there is a slowdown by a constant factor.

LanguageExecution time
C / Odin1x
Java2x
Js6x
Lua / Python30-60x