Benchee v0.14.0 Benchee.Benchmark.Scenario View Source
A Scenario in Benchee is a particular case of a whole benchmarking suite. That
is the combination of a particular function to benchmark (job_name and
function) in combination with a specific input (input_name and input).
It then gathers all data measured for this particular combination during
Benchee.Benchmark.measure/3 (run_times and memory_usages),
which are then used later in the process by Benchee.Statistics to compute
the relevant statistics (run_time_statistics and memory_usage_statistics).
name is the name that should be used by formatters to display scenarios as
it potentially includes the tag present when loading scenarios that were
saved before. See display_name/1.
Link to this section Summary
Functions
Returns true if data of the provided type has been fully procsessed, false otherwise
Returns the correct name to display of the given scenario data
Link to this section Types
t()
View Source
t() :: %Benchee.Benchmark.Scenario{
after_each: (... -> any()) | nil,
after_scenario: (... -> any()) | nil,
before_each: (... -> any()) | nil,
before_scenario: (... -> any()) | nil,
function: (... -> any()),
input: any() | nil,
input_name: String.t() | nil,
job_name: String.t(),
memory_usage_statistics: Benchee.Statistics.t() | nil,
memory_usages: [non_neg_integer()],
name: String.t(),
run_time_statistics: Benchee.Statistics.t() | nil,
run_times: [float()],
tag: String.t() | nil
}
t() :: %Benchee.Benchmark.Scenario{
after_each: (... -> any()) | nil,
after_scenario: (... -> any()) | nil,
before_each: (... -> any()) | nil,
before_scenario: (... -> any()) | nil,
function: (... -> any()),
input: any() | nil,
input_name: String.t() | nil,
job_name: String.t(),
memory_usage_statistics: Benchee.Statistics.t() | nil,
memory_usages: [non_neg_integer()],
name: String.t(),
run_time_statistics: Benchee.Statistics.t() | nil,
run_times: [float()],
tag: String.t() | nil
}
Link to this section Functions
data_processed?(scenario, atom) View Source
Returns true if data of the provided type has been fully procsessed, false otherwise.
Current available types are run_time and memory. Reasons they might not have been processed
yet are:
- Suite wasn't configured to collect them at all
Benchee.statistics/1hasn't been called yet so that data was collected but statistics aren't present yet
Examples
iex> alias Benchee.Benchmark.Scenario
iex> alias Benchee.Statistics
iex> scenario = %Scenario{run_time_statistics: %Statistics{sample_size: 100}}
iex> Scenario.data_processed?(scenario, :run_time)
true
iex> scenario = %Scenario{memory_usage_statistics: %Statistics{sample_size: 1}}
iex> Scenario.data_processed?(scenario, :memory)
true
iex> scenario = %Scenario{memory_usage_statistics: %Statistics{sample_size: 0}}
iex> Scenario.data_processed?(scenario, :memory)
false
display_name(map) View Source
Returns the correct name to display of the given scenario data.
In the normal case this is job_name, however when scenarios are loaded they
are tagged and these tags should be shown for disambiguation.
Examples
iex> alias Benchee.Benchmark.Scenario
iex> Scenario.display_name(%Scenario{job_name: "flat_map"})
"flat_map"
iex> Scenario.display_name(%Scenario{job_name: "flat_map", tag: "master"})
"flat_map (master)"
iex> Scenario.display_name(%{job_name: "flat_map"})
"flat_map"