Skip to content

Commit

Permalink
Update & adapt to new benchee version
Browse files Browse the repository at this point in the history
  • Loading branch information
PragTob committed Mar 17, 2019
1 parent b3b8f76 commit 6c3d1b7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 30 deletions.
50 changes: 27 additions & 23 deletions lib/benchee/formatters/csv.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,37 @@ defmodule Benchee.Formatters.CSV do
iex> suite = %Benchee.Suite{
...> scenarios: [
...> %Benchee.Benchmark.Scenario{
...> %Benchee.Scenario{
...> name: "My Job",
...> run_times: [500],
...> memory_usages: [500],
...> input_name: "Some Input",
...> input: "Some Input",
...> run_time_statistics: %Benchee.Statistics{
...> average: 500.0,
...> ips: 2000.0,
...> std_dev: 200.0,
...> std_dev_ratio: 0.4,
...> std_dev_ips: 800.0,
...> median: 450.0,
...> minimum: 200,
...> maximum: 900,
...> sample_size: 8
...> run_time_data: %Benchee.CollectionData{
...> samples: [500],
...> statistics: %Benchee.Statistics{
...> average: 500.0,
...> ips: 2000.0,
...> std_dev: 200.0,
...> std_dev_ratio: 0.4,
...> std_dev_ips: 800.0,
...> median: 450.0,
...> minimum: 200,
...> maximum: 900,
...> sample_size: 8
...> }
...> },
...> memory_usage_statistics: %Benchee.Statistics{
...> average: 500.0,
...> ips: nil,
...> std_dev: 200.0,
...> std_dev_ratio: 0.4,
...> std_dev_ips: nil,
...> median: 450.0,
...> minimum: 200,
...> maximum: 900,
...> sample_size: 8
...> memory_usage_data: %Benchee.CollectionData{
...> samples: [500],
...> statistics: %Benchee.Statistics{
...> average: 500.0,
...> ips: nil,
...> std_dev: 200.0,
...> std_dev_ratio: 0.4,
...> std_dev_ips: nil,
...> median: 450.0,
...> minimum: 200,
...> maximum: 900,
...> sample_size: 8
...> }
...> }
...> }
...> ]
Expand Down
4 changes: 2 additions & 2 deletions lib/benchee/formatters/csv/raw.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Benchee.Formatters.CSV.Raw do
Functionality for converting Benchee scenarios to raw csv.
"""

alias Benchee.Benchmark.Scenario
alias Benchee.Scenario

@doc false
def add_headers(measurements, scenarios) do
Expand All @@ -19,7 +19,7 @@ defmodule Benchee.Formatters.CSV.Raw do
end

@doc false
def to_csv(scenario), do: [scenario.run_times, scenario.memory_usages]
def to_csv(scenario), do: [scenario.run_time_data.samples, scenario.memory_usage_data.samples]

@no_input Benchee.Benchmark.no_input()
defp input_part(%Scenario{input_name: nil}), do: ""
Expand Down
6 changes: 3 additions & 3 deletions lib/benchee/formatters/csv/statistics.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Benchee.Formatters.CSV.Statistics do
Functionality for converting Benchee scenarios to csv with statistics.
"""

alias Benchee.{Benchmark.Scenario, Statistics}
alias Benchee.{Scenario, Statistics}

@headers_without_memory [
"Name",
Expand Down Expand Up @@ -44,8 +44,8 @@ defmodule Benchee.Formatters.CSV.Statistics do
def to_csv(%Scenario{
name: name,
input_name: input_name,
memory_usage_statistics: memory_usage_statistics,
run_time_statistics: run_time_statistics
memory_usage_data: %{statistics: memory_usage_statistics},
run_time_data: %{statistics: run_time_statistics}
}) do
[name, input_name] ++
to_csv(:run_time, run_time_statistics) ++ to_csv(:memory, memory_usage_statistics)
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ defmodule BencheeCSV.Mixfile do

defp deps do
[
{:benchee, "~> 0.14"},
{:benchee, "~> 0.14", github: "PragTob/benchee"},
{:csv, "~> 2.0"},
{:excoveralls, "~> 0.10.0", only: :test},
{:credo, "~> 1.0", only: :dev},
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%{
"benchee": {:hex, :benchee, "0.14.0", "f771f587c48b4824b497e2a3e374f75e93ef01fc329873b089a3f5dd961b80b8", [:mix], [{:deep_merge, "~> 0.1", [hex: :deep_merge, repo: "hexpm", optional: false]}], "hexpm"},
"benchee": {:git, "https://github.com/PragTob/benchee.git", "de9e99462f6e5ad03001460391a8bd82dbbba773", []},
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"},
"certifi": {:hex, :certifi, "2.4.2", "75424ff0f3baaccfd34b1214184b6ef616d89e420b258bb0a5ea7d7bc628f7f0", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"},
"credo": {:hex, :credo, "1.0.2", "88bc918f215168bf6ce7070610a6173c45c82f32baa08bdfc80bf58df2d103b6", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
Expand Down

0 comments on commit 6c3d1b7

Please sign in to comment.