perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marco <marcodis...@gmail.com>
Subject Re: Measuring response time Apache request
Date Tue, 24 May 2011 17:02:50 GMT
Il 24/05/2011 18.19, Torsten Förtsch ha scritto:
> On Tuesday, May 24, 2011 17:30:33 marco wrote:
>> I want to get the response time that Apache spends to serve a request
>> (from post-read-request phase to the response phase).
> PerlPostReadRequestHandler "sub {                \
>    use Time::HiRes();                             \
>    use Apache2::RequestUtil();                    \
>    $_[0]->pnotes->{starttime}=Time::HiRes::time;  \
>    0;                                             \
> }"
>
> Then in the PerlResponseHandler you can do:
>
>    $elapsed=Time::HiRes::time-$r->pnotes->{starttime};
>
> Torsten Förtsch
>
Hi,
I follow your suggest using Time::HiRes but I have an error when I try 
to start apache. Here's my code(it is only an example):
This is the script that will be executed as response handler, but it 
doesn't work because doesn't print the time.
*use strict;
   use warnings;

   use Time::HiRes qw(gettimeofday tv_interval);

   use Apache2::RequestRec ();
   use Apache2::RequestIO ();

   use Apache2::Const -compile => 'OK';

   sub handler{
     my $r = shift;
     my $start_time = [ gettimeofday ];
     my $end_time = [ gettimeofday ];
     my $elapsed = tv_interval($start_time,$end_time);
     $r->send_http_header('text/html');
     $r->print ($elapsed);
     return Apache2::Const::OK;
    }
    1;
*
In httpd.conf file I have:

PerlPostReadRequestHandler Dir::touch      #this script is well executed
PerlResponseHandler Dir::timediff                #this handler (below) 
is not executed!!!!!!!!!!!!!!!!!!!

why it doesn't work?
Can you help me,please?
Thanks for your answers!





Mime
View raw message