Profile of Hash/Merge/Simple.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:56 2012

Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Hash/Merge/Simple.pm
Statements | Executed 197 statements in 482µs

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
8 | 2 | 2 | 198µs | 198µs | Hash::Merge::Simple::::mergeHash::Merge::Simple::merge (recurses: max depth 2, inclusive time 165µs)
1 | 1 | 1 | 9µs | 9µs | Hash::Merge::Simple::::BEGIN@2Hash::Merge::Simple::BEGIN@2
1 | 1 | 1 | 8µs | 25µs | Hash::Merge::Simple::::BEGIN@7Hash::Merge::Simple::BEGIN@7
1 | 1 | 1 | 7µs | 10µs | Hash::Merge::Simple::::BEGIN@8Hash::Merge::Simple::BEGIN@8
1 | 1 | 1 | 7µs | 42µs | Hash::Merge::Simple::::BEGIN@10Hash::Merge::Simple::BEGIN@10
0 | 0 | 0 | 0s | 0s | Hash::Merge::Simple::::clone_mergeHash::Merge::Simple::clone_merge
0 | 0 | 0 | 0s | 0s | Hash::Merge::Simple::::dclone_mergeHash::Merge::Simple::dclone_merge

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

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Hash::Merge::Simple;
2 |  |  |  |  | # spent 9µs within Hash::Merge::Simple::BEGIN@2 which was called: # once (9µs+0s) by Tapper::Config::BEGIN@18 at line 4 BEGIN {
3 | 1 | 8µs |  |  | $Hash::Merge::Simple::VERSION = '0.051';
4 | 1 | 14µs | 1 | 9µs | } # spent 9µs making 1 call to Hash::Merge::Simple::BEGIN@2
5 |  |  |  |  | # ABSTRACT: Recursively merge two or more hashes, simply
6 |  |  |  |  |
7 | 3 | 19µs | 2 | 41µs | # spent 25µs (8+16) within Hash::Merge::Simple::BEGIN@7 which was called: # once (8µs+16µs) by Tapper::Config::BEGIN@18 at line 7 use warnings; # spent 25µs making 1 call to Hash::Merge::Simple::BEGIN@7 # spent 16µs making 1 call to warnings::import
8 | 3 | 20µs | 2 | 13µs | # spent 10µs (7+3) within Hash::Merge::Simple::BEGIN@8 which was called: # once (7µs+3µs) by Tapper::Config::BEGIN@18 at line 8 use strict; # spent 10µs making 1 call to Hash::Merge::Simple::BEGIN@8 # spent 3µs making 1 call to strict::import
9 |  |  |  |  |
10 | 3 | 211µs | 2 | 76µs | # spent 42µs (7+34) within Hash::Merge::Simple::BEGIN@10 which was called: # once (7µs+34µs) by Tapper::Config::BEGIN@18 at line 10 use vars qw/ @ISA @EXPORT_OK /; # spent 42µs making 1 call to Hash::Merge::Simple::BEGIN@10 # spent 34µs making 1 call to vars::import
11 | 1 | 700ns |  |  | require Exporter;
12 | 1 | 7µs |  |  | @ISA = qw/ Exporter /;
13 | 1 | 1µs |  |  | @EXPORT_OK = qw/ merge clone_merge dclone_merge /;
14 |  |  |  |  |
15 |  |  |  |  |
16 |  |  |  |  | # This was stoled from Catalyst::Utils... thanks guys!
17 |  |  |  |  | sub merge (@);
18 |  |  |  |  | # spent 198µs (198+-0ns) within Hash::Merge::Simple::merge which was called 8 times, avg 25µs/call: # 7 times (127µs+-127µs) by Hash::Merge::Simple::merge at line 34, avg 0s/call # once (71µs+127µs) by Tapper::Config::_switch_context at line 75 of Tapper/Config.pm sub merge (@) {
19 | 64 | 94µs |  |  | shift unless ref $_[0]; # Take care of the case we're called like Hash::Merge::Simple->merge(...)
20 |  |  |  |  | my ($left, @right) = @_;
21 |  |  |  |  |
22 |  |  |  |  | return $left unless @right;
23 |  |  |  |  |
24 |  |  |  |  | return merge($left, merge(@right)) if @right > 1;
25 |  |  |  |  |
26 |  |  |  |  | my ($right) = @right;
27 |  |  |  |  |
28 |  |  |  |  | my %merge = %$left;
29 |  |  |  |  |
30 |  |  |  |  | for my $key (keys %$right) {
31 |  |  |  |  |
32 | 84 | 89µs |  |  | my ($hr, $hl) = map { ref $_->{$key} eq 'HASH' } $right, $left;
33 |  |  |  |  |
34 | 35 | 15µs | 7 | 0s | if ($hr and $hl){ # spent 165µs making 7 calls to Hash::Merge::Simple::merge, avg 24µs/call, recursion: max depth 2, sum of overlapping time 165µs
35 |  |  |  |  | $merge{$key} = merge($left->{$key}, $right->{$key});
36 |  |  |  |  | }
37 |  |  |  |  | else {
38 |  |  |  |  | $merge{$key} = $right->{$key};
39 |  |  |  |  | }
40 |  |  |  |  | }
41 |  |  |  |  |
42 |  |  |  |  | return \%merge;
43 |  |  |  |  | }
44 |  |  |  |  |
45 |  |  |  |  |
46 |  |  |  |  | sub clone_merge {
47 |  |  |  |  | require Clone;
48 |  |  |  |  | my $result = merge @_;
49 |  |  |  |  | return Clone::clone( $result );
50 |  |  |  |  | }
51 |  |  |  |  |
52 |  |  |  |  |
53 |  |  |  |  | sub dclone_merge {
54 |  |  |  |  | require Storable;
55 |  |  |  |  | my $result = merge @_;
56 |  |  |  |  | return Storable::dclone( $result );
57 |  |  |  |  | }
58 |  |  |  |  |
59 |  |  |  |  |
60 | 1 | 4µs |  |  | 1;
61 |  |  |  |  |
62 |  |  |  |  | __END__