View Source Benchee.Formatter behaviour (Benchee v1.2.0)
Defines a behaviour for formatters in Benchee, and functions to work with these.
When implementing a Benchee formatter as a behaviour please adopt this
behaviour, as it helps with uniformity and also allows at least the .format
function of formatters to be run in parallel.
The module itself then has functions to deal with formatters defined in this way
allowing for parallel output through output/1
or just output a single formatter
through output/3
.
Summary
Callbacks
Takes the suite and returns whatever representation the formatter wants to use
to output that information. It is important that this function needs to be
pure (aka have no side effects) as Benchee will run format/1
functions
of multiple formatters in parallel. The result will then be passed to
write/1
.
Takes the return value of format/1
and then performs some I/O for the user
to actually see the formatted data (UI, File IO, HTTP, ...)
Functions
Format and output all configured formatters and formatting functions.
Output a suite with a given formatter and options.
Types
@type options() :: any()
Options given to formatters, entirely defined by formatter authors.
Callbacks
@callback format(Benchee.Suite.t(), options()) :: any()
Takes the suite and returns whatever representation the formatter wants to use
to output that information. It is important that this function needs to be
pure (aka have no side effects) as Benchee will run format/1
functions
of multiple formatters in parallel. The result will then be passed to
write/1
.
Takes the return value of format/1
and then performs some I/O for the user
to actually see the formatted data (UI, File IO, HTTP, ...)
Functions
@spec output(Benchee.Suite.t()) :: Benchee.Suite.t()
Format and output all configured formatters and formatting functions.
Expects a suite that already has been run through all previous functions so has the aggregated statistics etc. that the formatters rely on.
Works by invoking the format/2
and write/2
functions defined in this module. The format/2
functions are actually called in parallel (as they should be pure) - due to potential
interference the write/2
functions are called serial.
Also handles pure functions that will then be called with the suite.
You can't rely on the formatters being called in pre determined order.
@spec output(Benchee.Suite.t(), module(), options()) :: Benchee.Suite.t()
Output a suite with a given formatter and options.
Replacement for the old MyFormatter.output/1
- calls format/2
and write/2
one after another
to create the output defined by the given formatter module. For the given options please refer
to the documentation of the formatters you use.