| Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Log/Log4perl/NDC.pm |
| Statements | Executed 11 statements in 209µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 25µs | 25µs | Log::Log4perl::NDC::BEGIN@5 |
| 1 | 1 | 1 | 7µs | 10µs | Log::Log4perl::NDC::BEGIN@6 |
| 1 | 1 | 1 | 6µs | 17µs | Log::Log4perl::NDC::BEGIN@7 |
| 0 | 0 | 0 | 0s | 0s | Log::Log4perl::NDC::get |
| 0 | 0 | 0 | 0s | 0s | Log::Log4perl::NDC::pop |
| 0 | 0 | 0 | 0s | 0s | Log::Log4perl::NDC::push |
| 0 | 0 | 0 | 0s | 0s | Log::Log4perl::NDC::remove |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | ################################################## | ||||
| 2 | package Log::Log4perl::NDC; | ||||
| 3 | ################################################## | ||||
| 4 | |||||
| 5 | 3 | 34µs | 1 | 25µs | # spent 25µs within Log::Log4perl::NDC::BEGIN@5 which was called:
# once (25µs+0s) by Log::Log4perl::Layout::PatternLayout::BEGIN@16 at line 5 # spent 25µs making 1 call to Log::Log4perl::NDC::BEGIN@5 |
| 6 | 3 | 17µs | 2 | 13µs | # spent 10µs (7+3) within Log::Log4perl::NDC::BEGIN@6 which was called:
# once (7µs+3µs) by Log::Log4perl::Layout::PatternLayout::BEGIN@16 at line 6 # spent 10µs making 1 call to Log::Log4perl::NDC::BEGIN@6
# spent 3µs making 1 call to strict::import |
| 7 | 3 | 155µs | 2 | 28µs | # spent 17µs (6+11) within Log::Log4perl::NDC::BEGIN@7 which was called:
# once (6µs+11µs) by Log::Log4perl::Layout::PatternLayout::BEGIN@16 at line 7 # spent 17µs making 1 call to Log::Log4perl::NDC::BEGIN@7
# spent 11µs making 1 call to warnings::import |
| 8 | |||||
| 9 | 1 | 400ns | our @NDC_STACK = (); | ||
| 10 | 1 | 2µs | our $MAX_SIZE = 5; | ||
| 11 | |||||
| 12 | ########################################### | ||||
| 13 | sub get { | ||||
| 14 | ########################################### | ||||
| 15 | if(@NDC_STACK) { | ||||
| 16 | # Return elements blank separated | ||||
| 17 | return join " ", @NDC_STACK; | ||||
| 18 | } else { | ||||
| 19 | return "[undef]"; | ||||
| 20 | } | ||||
| 21 | } | ||||
| 22 | |||||
| 23 | ########################################### | ||||
| 24 | sub pop { | ||||
| 25 | ########################################### | ||||
| 26 | if(@NDC_STACK) { | ||||
| 27 | return pop @NDC_STACK; | ||||
| 28 | } else { | ||||
| 29 | return undef; | ||||
| 30 | } | ||||
| 31 | } | ||||
| 32 | |||||
| 33 | ########################################### | ||||
| 34 | sub push { | ||||
| 35 | ########################################### | ||||
| 36 | my($self, $text) = @_; | ||||
| 37 | |||||
| 38 | unless(defined $text) { | ||||
| 39 | # Somebody called us via Log::Log4perl::NDC::push("blah") ? | ||||
| 40 | $text = $self; | ||||
| 41 | } | ||||
| 42 | |||||
| 43 | if(@NDC_STACK >= $MAX_SIZE) { | ||||
| 44 | CORE::pop(@NDC_STACK); | ||||
| 45 | } | ||||
| 46 | |||||
| 47 | return push @NDC_STACK, $text; | ||||
| 48 | } | ||||
| 49 | |||||
| 50 | ########################################### | ||||
| 51 | sub remove { | ||||
| 52 | ########################################### | ||||
| 53 | @NDC_STACK = (); | ||||
| 54 | } | ||||
| 55 | |||||
| 56 | __END__ |