Benchee v0.13.0 Benchee.Formatters.Console.RunTime View Source

This deals with just the formatting of the run time results. They are similar to the way the memory results are formatted, but different enough to where the abstractions start to break down pretty significantly, so I wanted to extract these two things into separate modules to avoid confusion.

Link to this section Summary

Functions

Formats the run time statistics to a report suitable for output on the CLI

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

Link to this function format_scenarios(scenarios, config) View Source
format_scenarios([Benchee.Benchmark.Scenario.t()], map()) :: [String.t(), ...]

Formats the run time statistics to a report suitable for output on the CLI.

Examples

iex> memory_statistics = %Benchee.Statistics{average: 100.0}
iex> scenarios = [
...>   %Benchee.Benchmark.Scenario{
...>     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},
...>       minimum: 100.1, maximum: 200.2, sample_size: 10_101, mode: 333.2
...>     },
...>     memory_usage_statistics: memory_statistics
...>   },
...>   %Benchee.Benchmark.Scenario{
...>     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},
...>       minimum: 200.2, maximum: 400.4, sample_size: 20_202, mode: [612.3, 554.1]
...>     },
...>     memory_usage_statistics: memory_statistics
...>   }
...> ]
iex> configuration = %{comparison: false, unit_scaling: :best, extended_statistics: true}
iex> Benchee.Formatters.Console.RunTime.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
",
"
Extended statistics: 
",
"
Name           minimum        maximum    sample size                     mode
",
"My Job       100.10 μs      200.20 μs        10.10 K                333.20 μs
",
"Job 2        200.20 μs      400.40 μs        20.20 K     612.30 μs, 554.10 μs
"]