From 5e85d9888f4440309cb0d2d06a79aff5d4c1c482 Mon Sep 17 00:00:00 2001 From: vfilippov Date: Wed, 26 Aug 2009 18:03:52 +0000 Subject: [PATCH] Bug 40933 Profiling... Unhappy :( git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@308 6955db30-a419-402b-8a0d-67ecbb4d7f56 --- HTTPServerSimple-NYTProf.sh | 3 ++- HTTPServerSimple.pl | 30 +++++++++++++++++++++++++++++- buglist.cgi | 2 ++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/HTTPServerSimple-NYTProf.sh b/HTTPServerSimple-NYTProf.sh index f62e0061a..7006420aa 100755 --- a/HTTPServerSimple-NYTProf.sh +++ b/HTTPServerSimple-NYTProf.sh @@ -1,3 +1,4 @@ #!/bin/sh -NYTPROF=clock=2:savesrc=1:file=/home/www/b3profile.out perl -d:NYTProf ./HTTPServerSimple.pl $* +#NYTPROF=clock=2:savesrc=1:file=/home/www/b3profile.out perl -d:NYTProf ./HTTPServerSimple.pl $* +NYTPROF=savesrc=1:file=/home/www/b3profile.out perl -d:NYTProf ./HTTPServerSimple.pl $* diff --git a/HTTPServerSimple.pl b/HTTPServerSimple.pl index 12e594c1f..7b5148547 100755 --- a/HTTPServerSimple.pl +++ b/HTTPServerSimple.pl @@ -15,11 +15,12 @@ $CGI::USE_PARAM_SEMICOLONS = 0; my $server = Bugzilla::HTTPServerSimple->new(8157); *CORE::GLOBAL::exit = sub { die bless { rc => shift }, 'Bugzilla::HTTPServerSimple::FakeExit'; }; -$SIG{INT} = sub { CORE::exit(); }; +$SIG{INT} = sub { warn "Terminating"; CORE::exit(); }; $server->run(); package Bugzilla::HTTPServerSimple; +use Bugzilla; use Time::HiRes qw(gettimeofday tv_interval); use IO::SendFile qw(sendfile); use base qw(HTTP::Server::Simple::CGI); @@ -47,6 +48,17 @@ sub handle_request close $fd; return 200; } + $Bugzilla::_request_cache = {}; + if ($ENV{NYTPROF} && $INC{'Devel/NYTProf.pm'}) + { + # use require() when running under NYTProf profiler + my $start = [gettimeofday]; + delete $INC{$script}; + require $script; + my $elapsed = tv_interval($start) * 1000; + warn "Served $script via require() in $elapsed ms"; + return 200; + } if (!$subs{$script}) { my $content; @@ -80,6 +92,22 @@ sub handle_request return 404; } +sub parse_headers +{ + my $self = shift; + my @headers; + my $chunk; + while ($chunk = ) + { + $chunk =~ s/[\r\l\n\s]+$//so; + if ($chunk =~ /^([^()<>\@,;:\\"\/\[\]?={} \t]+):\s*(.*)/i) { + push @headers, $1 => $2; + } + last if $chunk =~ /^$/so; + } + return \@headers; +} + package Bugzilla::HTTPServerSimple::FakeExit; 1; diff --git a/buglist.cgi b/buglist.cgi index aff9c3076..16ee74e12 100755 --- a/buglist.cgi +++ b/buglist.cgi @@ -1197,3 +1197,5 @@ $template->process($format->{'template'}, $vars) ################################################################################ print $cgi->multipart_final() if $serverpush; + +1;