Beamchmark.Formatter behaviour (Beamchmark v1.4.2)

Copy Markdown View Source

The module defines a behaviour that will be used to format and output Beamchmark.Suite. You can adopt this behaviour to implement custom formatters.

The module contains helper functions for validating and applying formatters defined in configuration of Beamchmark.Suite.

Summary

Types

Options given to formatters (defined by formatters authors).

t()

Represents a module implementing Beamchmark.Formatter behaviour.

Callbacks

Takes the suite and transforms it into some internal representation, that later on will be passed to write/2.

Works like format/2, but can provide additional information by comparing the latest suite with the previous one (passed as the second argument).

Takes the return value of format/1 or format/2 and outputs it in a convenient form (stdout, file, UI...).

Functions

Takes the suite and uses its formatters to output it. If the suite was configured with compare? flag enabled, the previous suite will be also provided to the formatters.

Types

options_t()

@type options_t() :: Keyword.t()

Options given to formatters (defined by formatters authors).

t()

@type t() :: module()

Represents a module implementing Beamchmark.Formatter behaviour.

Callbacks

format(t, options_t)

@callback format(Beamchmark.Suite.t(), options_t()) :: any()

Takes the suite and transforms it into some internal representation, that later on will be passed to write/2.

format(t, t, options_t)

@callback format(Beamchmark.Suite.t(), Beamchmark.Suite.t(), options_t()) :: any()

Works like format/2, but can provide additional information by comparing the latest suite with the previous one (passed as the second argument).

write(any, options_t)

@callback write(any(), options_t()) :: :ok

Takes the return value of format/1 or format/2 and outputs it in a convenient form (stdout, file, UI...).

Functions

output(suite)

@spec output(Beamchmark.Suite.t()) :: :ok

Takes the suite and uses its formatters to output it. If the suite was configured with compare? flag enabled, the previous suite will be also provided to the formatters.