Plack::Middleware::Profiler::NYTProf - Middleware for Profiling a Plack App
use Plack::Builder; builder { enable 'Profiler::NYTProf'; [ '200', [], [ 'Hello Profiler' ] ]; };
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.
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.
default
sub { 1 }
Use code reference if you want to enable profiling programmably This option is optional.
1
Devel::NYTProf doesn't generate HTML profiling report if you set 0 to this option. This option is optional.
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.
'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.
NYTProf write profile data to this directory. The default directory is current directory. This option is optional.
sub { '.' }
The file name about profile. This options is optional.
sub { my $id = $_[1]->{PROFILE_ID}; return "nytprof.$id.out"; }
Generate ID for every profile. This option is optional.
sub { return $$ . "-" . Time::HiRes::gettimeofday; } )
The file name of dummy profile for NYTProf. This option is optional.
'nytprof.null.out'
This is the hook before profiling This option is optional.
This is the hook after profiling This option is optional.
$ plackup -MPlack::App::Directory -e 'Plack::App::Directory->new({root => "./report"})->to_app'
This source is in Github:
http://github.com/dann/p5-plack-middleware-profiler-nytprof
Many thanks to: bayashi
Takatoshi Kitano <kitano.tk {at} gmail.com> Dai Okabayashi
Devel::NYTProf
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Plack::Middleware::Profiler::NYTProf, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plack::Middleware::Profiler::NYTProf
CPAN shell
perl -MCPAN -e shell install Plack::Middleware::Profiler::NYTProf
For more information on module installation, please visit the detailed CPAN module installation guide.