Bug 40933
Profiling... Unhappy :( git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@308 6955db30-a419-402b-8a0d-67ecbb4d7f56master
parent
95b390c532
commit
5e85d9888f
|
@ -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 $*
|
||||
|
|
|
@ -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 = <STDIN>)
|
||||
{
|
||||
$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;
|
||||
|
|
|
@ -1197,3 +1197,5 @@ $template->process($format->{'template'}, $vars)
|
|||
################################################################################
|
||||
|
||||
print $cgi->multipart_final() if $serverpush;
|
||||
|
||||
1;
|
||||
|
|
Loading…
Reference in New Issue