View Source erlperf_cli (erlperf v2.3.0)
Command line interface adapter.
Exports functions to format erlperf:benchmark/3
output in the same way as command line interface.
#!/usr/bin/env escript
%%! +pc unicode -pa /home/max-au/git/max-au/erlperf/_build/default/lib/erlperf/ebin
-mode(compile).
main(_) ->
Report = erlperf:benchmark([
#{runner => fun() -> rand:uniform(10) end},
#{runner => {rand, mwc59, [1]}}
], #{report => full}, undefined),
Out = erlperf_cli:format(Report, #{format => extended, viewport_width => 120}),
io:format(Out),
halt(0).
Running the script produces following output: $ ./bench
Code || Samples Avg StdDev Median P99 Iteration Rel
{rand,mwc59,[1]} 1 3 80515 Ki 0.59% 80249 Ki 81067 Ki 12 ns 100%
#Fun<bench__escript__1674__432325__319865__16.0. 1 3 15761 Ki 0.48% 15726 Ki 15847 Ki 63 ns 20%
Link to this section Summary
Types
Defines text report format.
Functions
Formats result produced by erlperf:benchmark/3
.
Link to this section Types
-type format_options() :: #{viewport_width => pos_integer(), format => basic | extended | full}.
Defines text report format.
format
:basic
: default format containing only average throughput persample_duration
and average runner runtimeextended
: includes median, p99 and other metrics(default for 10 and more samples)full
: includes system information in addition toextended
output
viewport_width
: how wide the report can be, defaults toio:columns/0
. Falls back to 80 when terminal does not report width.
Link to this section Functions
-spec format(Reports, Options) -> iolist() when Reports :: [erlperf:report()], Options :: format_options().
Formats result produced by erlperf:benchmark/3
.