Profile of Log/Log4perl/Filter.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For xt/tapper-mcp-scheduler-with-db-longrun.t
Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:22:55 2012

Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Log/Log4perl/Filter.pm
Statements | Executed 21 statements in 408µs

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 26µs | 26µs | Log::Log4perl::Filter::::BEGIN@5Log::Log4perl::Filter::BEGIN@5
1 | 1 | 1 | 8µs | 63µs | Log::Log4perl::Filter::::BEGIN@9Log::Log4perl::Filter::BEGIN@9
1 | 1 | 1 | 7µs | 9µs | Log::Log4perl::Filter::::BEGIN@6Log::Log4perl::Filter::BEGIN@6
1 | 1 | 1 | 7µs | 7µs | Log::Log4perl::Filter::::BEGIN@10Log::Log4perl::Filter::BEGIN@10
1 | 1 | 1 | 6µs | 17µs | Log::Log4perl::Filter::::BEGIN@7Log::Log4perl::Filter::BEGIN@7
1 | 1 | 1 | 6µs | 32µs | Log::Log4perl::Filter::::BEGIN@12Log::Log4perl::Filter::BEGIN@12
1 | 1 | 1 | 3µs | 3µs | Log::Log4perl::Filter::::resetLog::Log4perl::Filter::reset
0 | 0 | 0 | 0s | 0s | Log::Log4perl::Filter::::by_nameLog::Log4perl::Filter::by_name
0 | 0 | 0 | 0s | 0s | Log::Log4perl::Filter::::newLog::Log4perl::Filter::new
0 | 0 | 0 | 0s | 0s | Log::Log4perl::Filter::::okLog::Log4perl::Filter::ok
0 | 0 | 0 | 0s | 0s | Log::Log4perl::Filter::::registerLog::Log4perl::Filter::register

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | ##################################################
2 |  |  |  |  | package Log::Log4perl::Filter;
3 |  |  |  |  | ##################################################
4 |  |  |  |  |
5 | 3 | 35µs | 1 | 26µs | # spent 26µs within Log::Log4perl::Filter::BEGIN@5 which was called: # once (26µs+0s) by Log::Log4perl::Config::BEGIN@12 at line 5 use 5.006; # spent 26µs making 1 call to Log::Log4perl::Filter::BEGIN@5
6 | 3 | 20µs | 2 | 11µs | # spent 9µs (7+2) within Log::Log4perl::Filter::BEGIN@6 which was called: # once (7µs+2µs) by Log::Log4perl::Config::BEGIN@12 at line 6 use strict; # spent 9µs making 1 call to Log::Log4perl::Filter::BEGIN@6 # spent 2µs making 1 call to strict::import
7 | 3 | 16µs | 2 | 27µs | # spent 17µs (6+10) within Log::Log4perl::Filter::BEGIN@7 which was called: # once (6µs+10µs) by Log::Log4perl::Config::BEGIN@12 at line 7 use warnings; # spent 17µs making 1 call to Log::Log4perl::Filter::BEGIN@7 # spent 10µs making 1 call to warnings::import
8 |  |  |  |  |
9 | 3 | 20µs | 2 | 118µs | # spent 63µs (8+55) within Log::Log4perl::Filter::BEGIN@9 which was called: # once (8µs+55µs) by Log::Log4perl::Config::BEGIN@12 at line 9 use Log::Log4perl::Level; # spent 63µs making 1 call to Log::Log4perl::Filter::BEGIN@9 # spent 55µs making 1 call to Log::Log4perl::Level::import
10 | 3 | 22µs | 1 | 7µs | # spent 7µs within Log::Log4perl::Filter::BEGIN@10 which was called: # once (7µs+0s) by Log::Log4perl::Config::BEGIN@12 at line 10 use Log::Log4perl::Config; # spent 7µs making 1 call to Log::Log4perl::Filter::BEGIN@10
11 |  |  |  |  |
12 | 3 | 288µs | 2 | 57µs | # spent 32µs (6+26) within Log::Log4perl::Filter::BEGIN@12 which was called: # once (6µs+26µs) by Log::Log4perl::Config::BEGIN@12 at line 12 use constant _INTERNAL_DEBUG => 0; # spent 32µs making 1 call to Log::Log4perl::Filter::BEGIN@12 # spent 26µs making 1 call to constant::import
13 |  |  |  |  |
14 | 1 | 500ns |  |  | our %FILTERS_DEFINED = ();
15 |  |  |  |  |
16 |  |  |  |  | ##################################################
17 |  |  |  |  | sub new {
18 |  |  |  |  | ##################################################
19 |  |  |  |  | my($class, $name, $action) = @_;
20 |  |  |  |  |
21 |  |  |  |  | print "Creating filter $name\n" if _INTERNAL_DEBUG;
22 |  |  |  |  |
23 |  |  |  |  | my $self = { name => $name };
24 |  |  |  |  | bless $self, $class;
25 |  |  |  |  |
26 |  |  |  |  | if(ref($action) eq "CODE") {
27 |  |  |  |  | # it's a code ref
28 |  |  |  |  | $self->{ok} = $action;
29 |  |  |  |  | } else {
30 |  |  |  |  | # it's something else
31 |  |  |  |  | die "Code for ($name/$action) not properly defined";
32 |  |  |  |  | }
33 |  |  |  |  |
34 |  |  |  |  | return $self;
35 |  |  |  |  | }
36 |  |  |  |  |
37 |  |  |  |  | ##################################################
38 |  |  |  |  | sub register { # Register a filter by name
39 |  |  |  |  | # (Passed on to subclasses)
40 |  |  |  |  | ##################################################
41 |  |  |  |  | my($self) = @_;
42 |  |  |  |  |
43 |  |  |  |  | by_name($self->{name}, $self);
44 |  |  |  |  | }
45 |  |  |  |  |
46 |  |  |  |  | ##################################################
47 |  |  |  |  | sub by_name { # Get/Set a filter object by name
48 |  |  |  |  | ##################################################
49 |  |  |  |  | my($name, $value) = @_;
50 |  |  |  |  |
51 |  |  |  |  | if(defined $value) {
52 |  |  |  |  | $FILTERS_DEFINED{$name} = $value;
53 |  |  |  |  | }
54 |  |  |  |  |
55 |  |  |  |  | if(exists $FILTERS_DEFINED{$name}) {
56 |  |  |  |  | return $FILTERS_DEFINED{$name};
57 |  |  |  |  | } else {
58 |  |  |  |  | return undef;
59 |  |  |  |  | }
60 |  |  |  |  | }
61 |  |  |  |  |
62 |  |  |  |  | ##################################################
63 |  |  |  |  | # spent 3µs within Log::Log4perl::Filter::reset which was called: # once (3µs+0s) by Log::Log4perl::Logger::reset at line 113 of Log/Log4perl/Logger.pm sub reset {
64 |  |  |  |  | ##################################################
65 | 1 | 4µs |  |  | %FILTERS_DEFINED = ();
66 |  |  |  |  | }
67 |  |  |  |  |
68 |  |  |  |  | ##################################################
69 |  |  |  |  | sub ok {
70 |  |  |  |  | ##################################################
71 |  |  |  |  | my($self, %p) = @_;
72 |  |  |  |  |
73 |  |  |  |  | print "Calling $self->{name}'s ok method\n" if _INTERNAL_DEBUG;
74 |  |  |  |  |
75 |  |  |  |  | # Force filter classes to define their own
76 |  |  |  |  | # ok(). Exempt are only sub {..} ok functions,
77 |  |  |  |  | # defined in the conf file.
78 |  |  |  |  | die "This is to be overridden by the filter" unless
79 |  |  |  |  | defined $self->{ok};
80 |  |  |  |  |
81 |  |  |  |  | # What should we set the message in $_ to? The most logical
82 |  |  |  |  | # approach seems to be to concat all parts together. If some
83 |  |  |  |  | # filter wants to dissect the parts, it still can examine %p,
84 |  |  |  |  | # which gets passed to the subroutine and contains the chunks
85 |  |  |  |  | # in $p{message}.
86 |  |  |  |  | # Split because of CVS
87 |  |  |  |  | local($_) = join $
88 |  |  |  |  | Log::Log4perl::JOIN_MSG_ARRAY_CHAR, @{$p{message}};
89 |  |  |  |  | print "\$_ is '$_'\n" if _INTERNAL_DEBUG;
90 |  |  |  |  |
91 |  |  |  |  | my $decision = $self->{ok}->(%p);
92 |  |  |  |  |
93 |  |  |  |  | print "$self->{name}'s ok'ed: ",
94 |  |  |  |  | ($decision ? "yes" : "no"), "\n" if _INTERNAL_DEBUG;
95 |  |  |  |  |
96 |  |  |  |  | return $decision;
97 |  |  |  |  | }
98 |  |  |  |  |
99 | 1 | 2µs |  |  | 1;
100 |  |  |  |  |
101 |  |  |  |  | __END__