Greetings everyone,

I thought I knew exactly how to accomplish this task. But apparently I don't.
I tried to add a timer that would measure the time it took Perl to produce (process) rendering any of my web pages -- not how long the Client (browser) took to load the page, or the server to send it.

Because Perl is so great, and because my functions, and subs are so effecient; I chose Time::HiRes, knowing we'd be talking milliseconds. Here's what I'm using:

#!/usr/bin/perl -Tw # heavily commented for the sake of this post # presents time in my chosen format use POSIX qw/strftime/; # used for the Perl page rendered time I'm trying to produce use Time::HiRes qw/gettimeofday tv_interval/; # trickery to send the page as application/xhtml+xml, # if the client supports it if ($ENV{'HTTP_ACCEPT'} =~ /application\/xhtml\+xml/) { print "content-type:application/xhtml+xml; charset=utf-8\n\n"; } else { print "content-type:text/html; charset=utf-8\n\n"; } # here's where I start my timer my $start_time = [gettimeofday]; # just to add some of my local routines to my @INC use lib './localincs/'; # again, my preferred time format (has nothing to do with my timer) my $utc_time = strftime('%F %T %z',localtime); ...yadda,yadda,yadda... # bottom of web page, just before </body></html> my $total_time = tv_interval($start_time); # the following line should present something like this: # Page processed by Perl <my Perl version number> in 0.00001 seconds # But only produces the Perl version number printf('Page processed by Perl %s in %.02f seconds',$],$total_time);
Can anyone see why the "elapsed/process time" isn't being produced?
Currently, it shows up as
in 0.00 seconds



Thanks for taking the time.

--chris

#!/usr/bin/perl -Tw
use perl::always;
my $perl_version = "5.12.4";
print $perl_version;

In reply to What's wrong with my Perl process timer? by taint

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.