NAME
Plack::Middleware::Profiler::NYTProf - Middleware for Profiling a Plack App
SYNOPSIS
use Plack::Builder;
builder {
enable 'Profiler::NYTProf';
[ '200', [], [ 'Hello Profiler' ] ];
};
DESCRIPTION
Plack::Middleware::Profiler::NYTProf helps you to get profiles of Plack App.
Enabling this middleware will result in a huge performance penalty. It is intended for use in development only.
Read Devel::NYTProf documentation if you use it for production. Some options of Devel::NYTProf is useful to reduce profling overhead. See MAKING_NYTPROF_FASTER section of NYTProf's pod.
OPTIONS
NOTE that some options expect a code reference. Maybe, you feel it is complicated. However that will enable to control them programmably. It is more useful to your apps.
- enable_profile
-
default
sub { 1 }
Use code reference if you want to enable profiling programmably This option is optional.
- enable_reporting
-
default
1
Devel::NYTProf doesn't generate HTML profiling report if you set 0 to this option. This option is optional.
- env_nytprof
-
Warning: This option is DEPRECAED from 0.16. Use NYTPROF environment variable.
This option set to $ENV{NYTPROF}. See Devel::NYTProf: NYTPROF ENVIRONMENT VARIABLE section. By default, Plack::Middleware::Profiler::NYTProf loads Devel::NYTProf lazily.
default
'start=no:sigexit=int'
NOTE that Devel::NYTProf expects to be loaded in compile phase. It would be better to load manually like this
# in your app.psgi BEGIN { use Plack::Middleware::Profiler::NYTProf; $ENV{NYTPROF} = 'start=no:sigexit=int:stmts=0:savesrc=0'; Plack::Middleware::Profiler::NYTProf->preload; }
If you set enable_reporting TRUE (you get a profile for each request), you should NOT load Devel::NYTProf manually.
- profiling_result_dir
-
NYTProf write profile data to this directory. The default directory is current directory. This option is optional.
default
sub { '.' }
- profiling_result_file_name
-
The file name about profile. This options is optional.
default
sub { my $id = $_[1]->{PROFILE_ID}; return "nytprof.$id.out"; }
- generate_profile_id
-
Generate ID for every profile. This option is optional.
default
sub { return $$ . "-" . Time::HiRes::gettimeofday; } )
- nullfile
-
The file name of dummy profile for NYTProf. This option is optional.
default
'nytprof.null.out'
- before_profile
-
This is the hook before profiling This option is optional.
- after_profile
-
This is the hook after profiling This option is optional.
HOW TO SEE REPORT
$ plackup -MPlack::App::Directory -e 'Plack::App::Directory->new({root => "./report"})->to_app'
SOURCE AVAILABILITY
This source is in Github:
http://github.com/dann/p5-plack-middleware-profiler-nytprof
CONTRIBUTORS
Many thanks to: bayashi
AUTHOR
Takatoshi Kitano <kitano.tk {at} gmail.com> Dai Okabayashi
SEE ALSO
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.