View Source Benchee.Conversion.Format behaviour (Benchee v1.3.0)

Functions for formatting values and their unit labels. Different domains handle this task differently, for example durations and counts.

See Benchee.Conversion.Count and Benchee.Conversion.Duration for examples.

Summary

Callbacks

Formats a number as a string, with a unit label. See Benchee.Conversion.Count and Benchee.Conversion.Duration for examples

Formats in a more "human" way, one biggest unit at a time.

Functions

Formats a unit value in the domain described by module. The module should provide a units/0 function that returns a Map like

Formats a unit value with specified label and separator

Human friendly duration format for time as a string.

Callbacks

@callback format(number()) :: String.t()

Formats a number as a string, with a unit label. See Benchee.Conversion.Count and Benchee.Conversion.Duration for examples

@callback format_human(number()) :: String.t()

Formats in a more "human" way, one biggest unit at a time.

So instead of 1.5h it says 1h 30min

Functions

Formats a unit value in the domain described by module. The module should provide a units/0 function that returns a Map like

%{ :unit_name => %Benchee.Conversion.Unit{ ... } }

Additionally, module may specify a separator/0 function, which provides a custom separator string that will appear between the value and label in the formatted output. If no separator/0 function exists, the default separator (a single space) will be used.

iex> format({1.0, :kilobyte}, Benchee.Conversion.Memory)
"1 KB"
Link to this function

format(number, label, separator)

View Source

Formats a unit value with specified label and separator

Link to this function

format_human(number, module)

View Source

Human friendly duration format for time as a string.

The output is a sequence of values and unit labels separated by a space. Only units whose value is non-zero are included in the output. The passed number is duration in the base unit - nanoseconds.