Skip to content

Commit

Permalink
Add warning when protocols are not consolidated
Browse files Browse the repository at this point in the history
This adds a warning when folks try to run benchmarks in environments
without protocol consolidation enabled.

I have no idea how to test this since you can't turn protocol
consolidation off at runtime, though.
  • Loading branch information
devonestes committed Jul 6, 2018
1 parent b0353c7 commit f03b40a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/benchee/system.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ defmodule Benchee.System do
cpu_speed: cpu_speed()
}

warn_about_performance_degrading_settings()

%Suite{suite | system: system_info}
end

Expand Down Expand Up @@ -164,4 +166,22 @@ defmodule Benchee.System do
output
end
end

defp warn_about_performance_degrading_settings do
unless all_protocols_consolidated?() do
IO.puts("""
Not all of your protocols have been consolidated. In order to achieve the
best possible accuracy for benchmarks, please ensure protocol
consolidation is enabled in your benchmarking environment.
""")
end
end

defp all_protocols_consolidated? do
path = :code.lib_dir(:elixir, :ebin)

[path]
|> Protocol.extract_protocols()
|> Enum.all?(&Protocol.consolidated?/1)
end
end

0 comments on commit f03b40a

Please sign in to comment.