DEV Community

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

Collapse
 
sjmulder profile image
Sijmen J. Mulder

As for actual examples, there's two that come to mind:

  • To temporarily replace Google reverse geolocation ("what city is this coordinate?") we exported data from OpenStreetMap to a file as binary records (e.g. 20 bytes for the name, 2 8-byte floats for coords, etc) and memory-mapped it to C# structs. Then used a simple Linq MinBy query checking squared distances. The JIT generated really tight vectorized code for this and it was super fast.
  • Did a POC for a pension fund rewriting some of the policy projection calculations in OpenCL to run on a graphics card. The original C# code wasn't bad but GPU performance was just another level!