Is there a fasterer version for elixir?

I did some searching but can’t find a library. Is there a fasterer (https://github.com/DamirSvrtan/fasterer) version for elixir?

I did have a look at:



None seem to offer a cli that just tells you which optimizations are worth changing.

1 Like

In general it is hard to detect wrong usages of these entries in the real code.

For example:

  • [value] ++ list has (almost?) the same performance as [value | list], so if you are appending to the front then the syntax doesn’t make much difference
  • Replacing gen_server with ETS isn’t so obvious and it has disadvantages on its own
  • There is no real solution for using atoms instead of strings for comparison, as changing strings to atoms is highly unsafe and slow on it’s own
  • You should never use raw spawn and spawn_link unless you really know what you are doing, and in such situation you probably know what are the performance differences
  • String.slice/3 cannot be safely changed to binary_part as these have different semantic (first one is UTF-8 safe while second is not)

Maybe some of them could be more or detected and informed, but in most cases it is not so obvious. In general idiomatic code will be fast enough. And when it is not fast then you should profile and benchmark. There is no “magic recepture” to make it fast on first try, especially as Elixir is more like Python in case of features rather than Ruby (“thing should have one, and only one idiomatic way to be done” rather than “there are few ways and it depends on you which one you will pick”). That is partially why :erlang.map_get/2 still do not have equivalent in Elixir and you need to use :erlang module.

5 Likes