Re: Timing component execution
Pedro Melo <[email protected]> Thu, 24 May 2012 16:49:25 +0100
| Newsgroups | gmane.comp.web.mason.devel |
|---|---|
| Message-ID | <CACCxPi2Oy61fzF4s3RcAjFiqyccgtv3+PU0HQZzArsVQqszH8g@mail.gmail.com> |
Hi,
sorry to respond to my own question, I've solved it, and though it my
be handy to others.
I used this package:
package My::App::Mason::Compilation;
use Poet qw($conf $env);
use Poet::Moose;
extends 'Mason::Compilation';
override 'output_class_header' => sub {
return join("\n", super(), 'use Time::HiRes ();');
};
override '_output_method' => sub {
my ($self, $method) = @_;
local $method->{init} = 'my $___t0 = [Time::HiRes::gettimeofday];
'.$method->{init};
local $method->{body} = 'print STDERR "HIT ".$self->cmeta->{path}."
".Time::HiRes::tv_interval($___t0)."\n";'.$method->{body};
super();
};
1;
Feel free to adjust the print STDERR to whatever you need it to be.
Bye,
On Thu, May 24, 2012 at 4:28 PM, Pedro Melo <[email protected]> wrote:
> Hi,
>
> I'm trying to time each Mason2 component execution to track some
> deviation on run times. I've tried adding a My::App::Mason::Component
> and override 'main', but main is the final method, it only exists on
> generated code.
>
> My next option is to override Mason::Compilation::_output_method but
> that means copying a lot of code.
>
> Before I start down this road, any other suggestions?
--
Pedro Melo
@pedromelo
http://www.simplicidade.org/
http://about.me/melo
xmpp:[email protected]
mailto:[email protected]
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/