summaryrefslogtreecommitdiffstats
path: root/mod_perl.pl
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2017-12-23 00:20:10 +0100
committerGitHub <noreply@github.com>2017-12-23 00:20:10 +0100
commit099ab661d00aaa29eb3ff00749fd851cdd15d4b5 (patch)
treeae3617908fc55e451117092020c1176ee0e68dee /mod_perl.pl
parentc2da016469427b2ffebaab0d38ca36b81281420c (diff)
downloadbugzilla-099ab661d00aaa29eb3ff00749fd851cdd15d4b5.tar.gz
bugzilla-099ab661d00aaa29eb3ff00749fd851cdd15d4b5.tar.xz
no bug - support Devel::NYTProf
Diffstat (limited to 'mod_perl.pl')
-rw-r--r--mod_perl.pl21
1 files changed, 20 insertions, 1 deletions
diff --git a/mod_perl.pl b/mod_perl.pl
index c682bece6..f94b7f7d4 100644
--- a/mod_perl.pl
+++ b/mod_perl.pl
@@ -24,6 +24,14 @@ BEGIN {
use Bugzilla::ModPerl::StartupFix;
+use constant USE_NYTPROF => !! $ENV{USE_NYTPROF};
+BEGIN {
+ if (USE_NYTPROF) {
+ $ENV{NYTPROF} = "savesrc=0:start=no:addpid=1";
+ }
+}
+use if USE_NYTPROF, 'Devel::NYTProf::Apache';
+
use Bugzilla::Constants ();
# If you have an Apache2::Status handler in your Apache configuration,
@@ -122,7 +130,7 @@ package Bugzilla::ModPerl::ResponseHandler;
use strict;
use base qw(ModPerl::Registry);
use Bugzilla;
-use Bugzilla::Constants qw(USAGE_MODE_REST);
+use Bugzilla::Constants qw(USAGE_MODE_REST bz_locations);
use Time::HiRes;
sub handler : method {
@@ -140,9 +148,20 @@ sub handler : method {
local *lib::import = sub {};
use warnings;
+ if (Bugzilla::ModPerl::USE_NYTPROF) {
+ state $count = {};
+ my $script = File::Basename::basename($ENV{SCRIPT_FILENAME});
+ $script =~ s/\.cgi$//;
+ my $file = bz_locations()->{datadir} . "/nytprof.$script." . ++$count->{$$};
+ DB::enable_profile($file);
+ }
Bugzilla::init_page();
my $start = Time::HiRes::time();
my $result = $class->SUPER::handler(@_);
+ if (Bugzilla::ModPerl::USE_NYTPROF) {
+ DB::disable_profile();
+ DB::finish_profile();
+ }
warn "[request_time] ", Bugzilla->cgi->request_uri, " took ", Time::HiRes::time() - $start, " seconds to execute";
# When returning data from the REST api we must only return 200 or 304,