Skip to content

Commit

Permalink
Backported fix for 0 runtime handling from #168
Browse files Browse the repository at this point in the history
  • Loading branch information
PragTob committed Jan 15, 2018
1 parent 0868adf commit 01b32dc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
elixir 1.6.0-rc.0
elixir 1.6.0-rc.1
erlang 20.2
2 changes: 1 addition & 1 deletion lib/benchee/benchmark/runner.ex
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ defmodule Benchee.Benchmark.Runner do
end

defp measure_runtimes(scenario, context, run_time, fast_warning)
defp measure_runtimes(scenario, _, 0, _), do: scenario
defp measure_runtimes(_, _, 0, _), do: []
defp measure_runtimes(scenario, scenario_context, run_time, fast_warning) do
end_time = current_time() + run_time
:erlang.garbage_collect
Expand Down
10 changes: 10 additions & 0 deletions test/benchee/benchmark/runner_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ defmodule Benchee.Benchmark.RunnerTest do
refute_receive :called
end

test "run times of the scenarios are empty when nothing runs" do
%{scenarios: [scenario]} =
%Suite{configuration: %{time: 0, warmup: 0}}
|> test_suite
|> Benchmark.benchmark("don't care", fn -> 0 end)
|> Benchmark.measure(TestPrinter)

assert scenario.run_times == []
end

@no_input Benchmark.no_input()
test "asks to print what is currently benchmarking" do
test_suite()
Expand Down

0 comments on commit 01b32dc

Please sign in to comment.