Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Defaults to `1_000_000`, setting it to `nil` gathers unlimited samples again (be
Especially important for run time, you can remove samples caused by garbage collection or external factors.
Defaults to `false`.
Shout out to [@NickNeck](https://github.com/NickNeck) who implemented this long wished for feature over in `Statistex`.
* Display `input_name` entries in Livebook/`Table.Reader` protocol. Thanks [@madlep](https://github.com/madlep)!

### Bugfixes (User Facing)
* fixed a bug where if times were supplied as `0` instead of `0.0` we'd sometimes gather a single measurement
Expand Down
2 changes: 2 additions & 0 deletions lib/benchee/benchmark.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ defmodule Benchee.Benchmark do
alias Benchee.Utility.DeepConvert

@no_input :__no_input
@type no_input :: :__no_input

@doc """
Public access for the special key representing no input for a scenario.
"""
@spec no_input() :: no_input()
def no_input, do: @no_input

@doc """
Expand Down
4 changes: 2 additions & 2 deletions lib/benchee/scenario.ex
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ defmodule Benchee.Scenario do
name: String.t(),
job_name: String.t(),
function: benchmarking_function,
input_name: String.t() | nil,
input: any | nil,
input_name: String.t() | Benchee.Benchmark.no_input(),
input: any | nil | Benchee.Benchmark.no_input(),
run_time_data: CollectionData.t(),
memory_usage_data: CollectionData.t(),
reductions_data: CollectionData.t(),
Expand Down
15 changes: 12 additions & 3 deletions lib/benchee/suite.ex
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ end

if Code.ensure_loaded?(Table.Reader) do
defimpl Table.Reader, for: Benchee.Suite do
alias Benchee.Benchmark
alias Benchee.CollectionData
alias Benchee.Scenario

Expand Down Expand Up @@ -96,7 +97,7 @@ if Code.ensure_loaded?(Table.Reader) do
Enum.map(fields, fn field -> "#{measurement_type}_#{field}" end)
end)

["job_name" | measurement_headers]
["job_name", "input_name"] ++ measurement_headers
end

defp fields_for(:run_time), do: @run_time_fields
Expand All @@ -106,14 +107,22 @@ if Code.ensure_loaded?(Table.Reader) do
config_percentiles = suite.configuration.percentiles

Enum.map_reduce(suite.scenarios, 0, fn %Scenario{} = scenario, count ->
secenario_data =
scenario_data =
Enum.flat_map(measurements_processed, fn measurement_type ->
scenario
|> Scenario.measurement_data(measurement_type)
|> get_stats_from_collection_data(measurement_type, config_percentiles)
end)

row = [scenario.job_name | secenario_data]
no_input = Benchmark.no_input()

input_name =
case scenario.input_name do
^no_input -> ""
name -> name
end

row = [scenario.name, input_name] ++ scenario_data

{row, count + 1}
end)
Expand Down
Loading
Loading