NAME

Devel::MojoProf::Reporter - Default mojo profile reporter

DESCRIPTION

Devel::MojoProf::Reporter is an object that is capable of reporting how long certain operations take.

See Devel::MojoProf for how to use this.

ATTRIBUTES

handler

my $cb       = $reporter->handler;
my $reporter = $reporter->handler(sub { ... });

Only useful to be back compat with Devel::MojoProf 0.01:

$prof->reporter(sub { ... });

Will be removed in the future.

out_csv

$str      = $reporter->out_csv;
$reporter = $reporter->out_csv("/path/to/file.csv");

Setting this attribute will cause "report" to print the results to a CSV file, instead of printing to STDERR. This will allow you to post-process the information in a structured way in your favorite spreadsheet editor.

You can also set the environment variable DEVEL_MOJOPROF_OUT_CSV to a given file or give it a special value "1", which will generate a file in the current directory for you, with the filename "devel-mojoprof-reporter-1548746277.csv", where "1548746277" will be the unix timestamp of when you started the run.

METHODS

report

$reporter->report(\%report);

Will be called every time a meassurement has been done by Devel::MojoProf.

The %report variable contains the following example information:

{
  file    => "path/to/app.pl",
  line    => 23,
  class   => "Mojo::Pg::Database",
  method  => "query_p",
  t0      => [Time::HiRes::gettimeofday],
  elapsed => Time::HiRes::tv_interval($report->{t0}),
  message => "SELECT 1 as whatever",
}

The %report above will print the following line to STDERR:

0.00038ms [Mojo::Pg::Database::query_p] SELECT 1 as whatever at path/to/app.pl line 23

The log format is currently EXPERIMENTAL and could be changed.

Note that the file and line keys can be disabled by setting the DEVEL_MOJOPROF_CALLER environment variable to "0". This can be useful to speed up the run of the program.

SEE ALSO

Devel::MojoProf.