Benchmarking

Improving static data performance with metaprogramming

In my previous post Generating static data with Elixir comprehensions I showed how you can use comprehensions to generate static data in your Elixir application. That static data was stored as a Map in a module attribute and accessible with a function that returns the Map itself.

When building your application, you probably know how the static data will be accessed. Elixir has various ways of accessing data in a List, Keyword, or Map, and there are big differences in performance based on the size of tha data set. We’ll use the library benchee to measure the differences between the built-in access functions and compare that to approaches based on metaprogramming.