Re: Timing component execution

Jonathan Swartz <[email protected]> Thu, 24 May 2012 10:02:58 -0700
Newsgroups gmane.comp.web.mason.devel
Message-ID <[email protected]>
Thanks Pedro. The fact that 'main' is difficult to override (because it's final) has come up as a problem before, so I'm thinking we need an intermediate method that can be more easily overriden. I'll take a look at this.

Incidentally, please use mason-users@ from now on - the list traffic is low enough as it is and there's certainly no reason to split it between two groups anymore (hasn't been for years). I'll shut down this list officially and transfer remaining users over when I get the chance.

Jon

On May 24, 2012, at 8:49 AM, Pedro Melo wrote:

> 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/
> _______________________________________________
> Mason-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mason-devel


------------------------------------------------------------------------------
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/