Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

Page load time

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


fayland at gmail

Apr 13, 2006, 11:46 PM

Post #1 of 2 (576 views)
Permalink
Page load time

Hi, all.

I need a function like "This page took 2.15273690223694 seconds to
load." so I create this patch against r3907
It's easy, just couple of lines. but it's difficult to write a
same-function plugin.

Index: Catalyst.pm

===================================================================

--- Catalyst.pm (revision 3907)

+++ Catalyst.pm (working copy)

@@ -1378,6 +1378,12 @@


$class->log->info(
"Request took ${elapsed}s ($av/s)\n" . $t->draw );
+
+ {
+ no strict 'refs';
+ *{"$class\::elapsed_time"} = sub { $elapsed };
+ }
+
}
else { $status = &$handler }

so that u can call "This page took [% c.elapsed_time %] seconds to
load." in TT files.
attachment is a patch, hope u guys like it.

--
Fayland Lam // http://www.fayland.org/
Attachments: catalyst.patch (0.45 KB)


nothingmuch at woobling

Apr 14, 2006, 2:02 AM

Post #2 of 2 (524 views)
Permalink
Re: Page load time [In reply to]

On Fri, Apr 14, 2006 at 07:46:00 +0000, fayland wrote:
> Hi, all.
>
> I need a function like "This page took 2.15273690223694 seconds to load." so I create this patch against r3907
> It's easy, just couple of lines. but it's difficult to write a same-function plugin.

It's better to put a time on your stash in begin/auto and extract it
from the stash on end time, because then you have control over where
it starts (what action), and then you know what you have to
optimize.

Either way, i'm not opposed to this patch as an API, but the
interface isn't very safe ;-)

--
Yuval Kogman <nothingmuch [at] woobling>
http://nothingmuch.woobling.org 0xEBD27418

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.