Skip to content

Instantly share code, notes, and snippets.



Last active May 12, 2017
What would you like to do?
Research: Why is single Elixir unit tests slow to run?

Instant-feeling unit tests improves productivity and developer happiness :)

Elixir tooling isn't quite there the way Ruby can be when optimized.

Ruby benchmarks:

  • instant 46ms base time (time ruby -e "")
  • instant 190ms running a ruby unit test doing nothing
  • in 50k line rails app:
    • okay 640ms bundler (time bundle exec ruby -e "")
    • okay 663ms running a ruby unit test

Elixir benchmarks:

  • instant 200ms base time (time elixir -e "IO.inspect 5+5")
  • fast 480ms in plain mix app (+280ms)
  • okay 673ms in phoenix app without database (+190ms)
  • slow 932ms in phoenix app with database (+260ms)
  • slow 1200ms in small phoenix app (+260ms)

Things that help:

  • Umbrella apps can separate dependencies and make it faster to run single tests

Things to try:

  • Debug what is taking so much time in each step
  • Can database connection be in a separate app from the schemas and other logic?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment