Benchee v0.10.0 Benchee.Formatters.Console View Source
Formatter to transform the statistics output into a structure suitable for
output through IO.write on the console.
Link to this section Summary
Link to this section Types
Link to this type
unit_per_statistic()
View Source
unit_per_statistic() :: %{optional(atom()) => Benchee.Conversion.Unit.t()}
Link to this section Functions
Formats the benchmark statistics to a report suitable for output on the CLI.
Returns a list of lists, where each list element is a group belonging to one
specific input. So if there only was one (or no) input given through :inputs
then there’s just one list inside.
Examples
iex> scenarios = [
...> %Benchee.Benchmark.Scenario{
...> job_name: "My Job", input_name: "My input", run_time_statistics: %Benchee.Statistics{
...> average: 200.0,ips: 5000.0,std_dev_ratio: 0.1, median: 190.0, percentiles: %{99 => 300.1}
...> }
...> },
...> %Benchee.Benchmark.Scenario{
...> job_name: "Job 2", input_name: "My input", run_time_statistics: %Benchee.Statistics{
...> average: 400.0, ips: 2500.0, std_dev_ratio: 0.2, median: 390.0, percentiles: %{99 => 500.1}
...> }
...> }
...> ]
iex> suite = %Benchee.Suite{
...> scenarios: scenarios,
...> configuration: %Benchee.Configuration{
...> formatter_options: %{
...> console: %{comparison: false}
...> },
...> unit_scaling: :best
...> }
...> }
iex> Benchee.Formatters.Console.format(suite)
[["
##### With input My input #####", "
Name ips average deviation median 99th %
",
"My Job 5 K 200 μs ±10.00% 190 μs 300.10 μs
",
"Job 2 2.50 K 400 μs ±20.00% 390 μs 500.10 μs
"]]
Link to this function
format_scenarios(scenarios, config)
View Source
format_scenarios([Benchee.Benchmark.Scenario.t()], map()) :: [any(), ...]
Formats the job statistics to a report suitable for output on the CLI.
Examples
iex> scenarios = [
...> %Benchee.Benchmark.Scenario{
...> job_name: "My Job", run_time_statistics: %Benchee.Statistics{
...> average: 200.0, ips: 5000.0,std_dev_ratio: 0.1, median: 190.0, percentiles: %{99 => 300.1}
...> }
...> },
...> %Benchee.Benchmark.Scenario{
...> job_name: "Job 2", run_time_statistics: %Benchee.Statistics{
...> average: 400.0, ips: 2500.0, std_dev_ratio: 0.2, median: 390.0, percentiles: %{99 => 500.1}
...> }
...> }
...> ]
iex> configuration = %{comparison: false, unit_scaling: :best}
iex> Benchee.Formatters.Console.format_scenarios(scenarios, configuration)
["
Name ips average deviation median 99th %
",
"My Job 5 K 200 μs ±10.00% 190 μs 300.10 μs
",
"Job 2 2.50 K 400 μs ±20.00% 390 μs 500.10 μs
"]
Combines format/1 and write/1 into a single convenience function that
is also chainable (as it takes a suite and returns a suite).
Takes the output of format/1 and writes that to the console.