| 1 | package Mail::MtPolicyd::Profiler; | ||||||||||
| 2 | |||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 7 | ▶ | use MooseX::Singleton; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 7 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 7 | ▶ | use Mail::MtPolicyd::Profiler::Timer; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 7 | ▶ | use JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 7 | our $VERSION = '2.01'; # VERSION | |||||||||
| 11 | # ABSTRACT: a application level profiler for mtpolicyd | ||||||||||
| 12 | |||||||||||
| 13 | has 'root' => ( is => 'rw', isa => 'Mail::MtPolicyd::Profiler::Timer', | ||||||||||
| 14 | lazy => 1, | ||||||||||
| 15 | default => sub { | ||||||||||
| 16 | 2 | ▶ | Mail::MtPolicyd::Profiler::Timer->new( name => 'main timer' ); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 17 | }, | ||||||||||
| 18 | 7 | ); | |||||||||
| 19 | |||||||||||
| 20 | has 'current' => ( | ||||||||||
| 21 | is => 'rw', isa => 'Mail::MtPolicyd::Profiler::Timer', | ||||||||||
| 22 | handles => { | ||||||||||
| 23 | 'tick' => 'tick', | ||||||||||
| 24 | }, | ||||||||||
| 25 | lazy => 1, | ||||||||||
| 26 | default => sub { | ||||||||||
| 27 | 2 | ▶ | my $self = shift; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 2 | return $self->root; | |||||||||
| 29 | }, | ||||||||||
| 30 | 7 | ); | |||||||||
| 31 | |||||||||||
| 32 | sub reset { | ||||||||||
| 33 | 1 | ▶ | my ( $self, $name ) = @_; | ||||||||
|
Subroutine
reset: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 34 | 1 | my $timer = Mail::MtPolicyd::Profiler::Timer->new( name => 'main timer' ); | |||||||||
| 35 | |||||||||||
| 36 | 1 | $self->root( $timer ); | |||||||||
| 37 | 1 | $self->current( $timer ); | |||||||||
| 38 | |||||||||||
| 39 | 1 | return; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | sub new_timer { | ||||||||||
| 43 | 5 | ▶ | my ( $self, $name ) = @_; | ||||||||
|
Subroutine
new_timer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 44 | 5 | my $timer = $self->current->new_child( name => $name ); | |||||||||
| 45 | 5 | $self->current( $timer ); | |||||||||
| 46 | 5 | return; | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | sub stop_current_timer { | ||||||||||
| 50 | 6 | ▶ | my ( $self, $name ) = @_; | ||||||||
|
Subroutine
stop_current_timer: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 51 | 6 | $self->current->stop; | |||||||||
| 52 | 6 | ▶ | if( defined $self->current->parent ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | 5 | $self->current($self->current->parent); | |||||||||
| 54 | } | ||||||||||
| 55 | 6 | return; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | sub to_string { | ||||||||||
| 59 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
to_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 60 | 1 | return $self->root->to_string; | |||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | 7 | __PACKAGE__->meta->make_immutable; | |||||||||
| 64 | |||||||||||
| 65 | 7 | 1; | |||||||||
| 66 | |||||||||||
| 67 | __END__ | ||||||||||
| 68 | |||||||||||
| 69 | =pod | ||||||||||
| 70 | |||||||||||
| 71 | =encoding UTF-8 | ||||||||||
| 72 | |||||||||||
| 73 | =head1 NAME | ||||||||||
| 74 | |||||||||||
| 75 | Mail::MtPolicyd::Profiler - a application level profiler for mtpolicyd | ||||||||||
| 76 | |||||||||||
| 77 | =head1 VERSION | ||||||||||
| 78 | |||||||||||
| 79 | version 2.01 | ||||||||||
| 80 | |||||||||||
| 81 | =head1 AUTHOR | ||||||||||
| 82 | |||||||||||
| 83 | Markus Benning <ich@markusbenning.de> | ||||||||||
| 84 | |||||||||||
| 85 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 86 | |||||||||||
| 87 | This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>. | ||||||||||
| 88 | |||||||||||
| 89 | This is free software, licensed under: | ||||||||||
| 90 | |||||||||||
| 91 | The GNU General Public License, Version 2, June 1991 | ||||||||||
| 92 | |||||||||||
| 93 | =cut | ||||||||||