bencheeorg / benchee

Easy and extensible benchmarking in Elixir providing you with lots of statistics!
MIT License
1.42k stars 66 forks source link

Benchee warning when used in mix task #370

Closed jaeyson closed 2 years ago

jaeyson commented 2 years ago

Hi! I'm using Benchee as a mix task for convenience reasons and it's working fine.

But it seems that it gave a warning (came from Elixir-LS and from my ci action):

Benchee.run/2 is undefined (module Benchee is not available or is yet to be defined)

Also ran Code.ensure_compiled!(Benchee) in an example file (.exs) and returns:

** (ArgumentError) could not load module Benchee due to reason :nofile

How do I get rid of the warning? or am I using it in a wrong way?

NickNeck commented 2 years ago

Hi @jaeyson

Are you sure you run your code in the same env as benchee was declared for. Maybe you run your code in Mix.env() == :test and your add {:benchee, "~> 1.1", only: :dev}.

jaeyson commented 2 years ago

Ah, that's the missing piece and it's working now :pray:. Quick question @NickNeck: why do we need to add it in test environment when it's not used? I've only used Benchee in mix task.