DEV Community

Discussion on: How Have You Refractored or Optimized Code for Improved Performance?

Collapse
 
codenameone profile image
Shai Almog

I have 3 performance tips:

  • Caching
  • Caching
  • Caching

It's almost always one form or another of caching (assuming it isn't a bug). One of the earliest examples I did of this was in the 80s where I pre-caculated the results of trig functions and stored them in an array. I could then perform trig calculations needed for my game with the cost of an array lookup.

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited

I totally relate to this. In the past I've made stuff like my own 3D engine, demoscene effects etc. in super low powered environments. The speed boost from using pre-calculated trig tables (and using plain integer arithmetic wherever possible) was huge!

Collapse
 
codenameone profile image
Shai Almog

That's great!

I remember doing that exact optimization in Turbo pascal in the early 90's when writing Wolfenstein 3d clones ;-)

Thread Thread
 
jonrandy profile image
Jon Randy 🎖️

Ah... back in the days when developers actually cared about performance 😉