Skip to content

Commit

Permalink
specify struct types in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
devonestes committed Feb 11, 2019
1 parent 09d321a commit 0ccf0cf
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 121 deletions.
2 changes: 1 addition & 1 deletion lib/benchee/collection_data.ex
Expand Up @@ -7,6 +7,6 @@ defmodule Benchee.CollectionData do

@type t :: %__MODULE__{
samples: [float | non_neg_integer],
statistics: Benchee.Statistics.t() | nil
statistics: Benchee.Statistics.t()
}
end
4 changes: 2 additions & 2 deletions lib/benchee/conversion.ex
Expand Up @@ -20,8 +20,8 @@ defmodule Benchee.Conversion do
iex> statistics = %Benchee.Statistics{average: 1_000_000.0, ips: 1000.0}
iex> scenario = %Benchee.Benchmark.Scenario{
...> run_time_data: %{statistics: statistics},
...> memory_usage_data: %{statistics: statistics}
...> run_time_data: %Benchee.CollectionData{statistics: statistics},
...> memory_usage_data: %Benchee.CollectionData{statistics: statistics}
...> }
iex> Benchee.Conversion.units([scenario], :best)
%{
Expand Down
10 changes: 4 additions & 6 deletions lib/benchee/formatters/console.ex
Expand Up @@ -23,7 +23,7 @@ defmodule Benchee.Formatters.Console do
```
iex> scenarios = [
...> %Benchee.Benchmark.Scenario{
...> name: "My Job", input_name: "My input", run_time_data: %{
...> name: "My Job", input_name: "My input", run_time_data: %Benchee.CollectionData{
...> statistics: %Benchee.Statistics{
...> average: 200.0,
...> ips: 5000.0,
Expand All @@ -32,11 +32,10 @@ defmodule Benchee.Formatters.Console do
...> percentiles: %{99 => 300.1},
...> sample_size: 200
...> }
...> },
...> memory_usage_data: %{statistics: %Benchee.Statistics{}}
...> }
...> },
...> %Benchee.Benchmark.Scenario{
...> name: "Job 2", input_name: "My input", run_time_data: %{
...> name: "Job 2", input_name: "My input", run_time_data: %Benchee.CollectionData{
...> statistics: %Benchee.Statistics{
...> average: 400.0,
...> ips: 2500.0,
Expand All @@ -45,8 +44,7 @@ defmodule Benchee.Formatters.Console do
...> percentiles: %{99 => 500.1},
...> sample_size: 200
...> }
...> },
...> memory_usage_data: %{statistics: %Benchee.Statistics{}}
...> }
...> }
...> ]
iex> suite = %Benchee.Suite{
Expand Down
8 changes: 4 additions & 4 deletions lib/benchee/formatters/console/run_time.ex
Expand Up @@ -38,23 +38,23 @@ defmodule Benchee.Formatters.Console.RunTime do
iex> scenarios = [
...> %Benchee.Benchmark.Scenario{
...> name: "My Job",
...> run_time_data: %{
...> run_time_data: %Benchee.CollectionData{
...> statistics: %Benchee.Statistics{
...> average: 200.0, ips: 5000.0,std_dev_ratio: 0.1, median: 190.0, percentiles: %{99 => 300.1},
...> minimum: 100.1, maximum: 200.2, sample_size: 10_101, mode: 333.2
...> },
...> },
...> memory_usage_data: %{statistics: memory_statistics}
...> memory_usage_data: %Benchee.CollectionData{statistics: memory_statistics}
...> },
...> %Benchee.Benchmark.Scenario{
...> name: "Job 2",
...> run_time_data: %{
...> run_time_data: %Benchee.CollectionData{
...> statistics: %Benchee.Statistics{
...> average: 400.0, ips: 2500.0, std_dev_ratio: 0.2, median: 390.0, percentiles: %{99 => 500.1},
...> minimum: 200.2, maximum: 400.4, sample_size: 20_202, mode: [612.3, 554.1]
...> }
...> },
...> memory_usage_data: %{statistics: memory_statistics}
...> memory_usage_data: %Benchee.CollectionData{statistics: memory_statistics}
...> }
...> ]
iex> configuration = %{comparison: false, unit_scaling: :best, extended_statistics: true}
Expand Down
4 changes: 2 additions & 2 deletions test/benchee/benchmark/runner_test.exs
Expand Up @@ -347,7 +347,7 @@ defmodule Benchee.Benchmark.RunnerTest do
suite = %Suite{
scenarios: [
%Scenario{
run_time_data: %{samples: [1_000_000]},
run_time_data: %Benchee.CollectionData{samples: [1_000_000]},
function: fn -> 1 + 1 end,
input: @no_input
}
Expand Down Expand Up @@ -675,7 +675,7 @@ defmodule Benchee.Benchmark.RunnerTest do
# should be closer to 10 by you know slow CI systems...
assert hook_call_count >= 2
# for every sample that we have, we should have run a hook
[%{run_time_data: %{samples: run_times}}] = result.scenarios
[%{run_time_data: %Benchee.CollectionData{samples: run_times}}] = result.scenarios
sample_size = length(run_times)
assert sample_size == hook_call_count
end
Expand Down

0 comments on commit 0ccf0cf

Please sign in to comment.