Search⌘ K
AI Features

Improving Performance at Compile Time

Explore techniques to improve Elixir application performance during testing by using compile-time configuration with Application.compile_env/3. Understand how to optimize external service calls by leveraging Mox.stub_with/2 to combine doubles and real modules for flexible tests. Learn to balance test isolation with performance in integration scenarios.

We'll cover the following...

The patterns we previously discussed are powerful and flexible, and they let us have fine-tuned control over testing interactions with external services. However, there’s still one principle we’re going against.We’re introducing a runtime call to decide which double to use in production code. That is, every time we call the rain?/2 function, we’ll call Application.get_env/3 (which is essentially a read from an ETS table) to get the double module we want to use.

In this case, the performance hit is negligible compared to the cost of the HTTP ...