Profile of Test/Deep/HashKeysOnly.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For t/app_dpath.t
Run on Tue Jun 5 15:25:28 2012
Reported on Tue Jun 5 15:26:01 2012

Filename | /home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Test/Deep/HashKeysOnly.pm
Statements | Executed 68 statements in 2.93ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
3 | 1 | 1 | 229µs | 343µs | Test::Deep::HashKeysOnly::::descend Test::Deep::HashKeysOnly::descend
3 | 1 | 1 | 112µs | 127µs | Test::Deep::HashKeysOnly::::init Test::Deep::HashKeysOnly::init
1 | 1 | 1 | 76µs | 93µs | Test::Deep::HashKeys::::BEGIN@1 Test::Deep::HashKeys::BEGIN@1
1 | 1 | 1 | 43µs | 72µs | Test::Deep::HashKeys::::BEGIN@2 Test::Deep::HashKeys::BEGIN@2
1 | 1 | 1 | 40µs | 285µs | Test::Deep::SubHashKeysOnly::::BEGIN@114 Test::Deep::SubHashKeysOnly::BEGIN@114
1 | 1 | 1 | 39µs | 440µs | Test::Deep::SuperHashKeysOnly::::BEGIN@100Test::Deep::SuperHashKeysOnly::BEGIN@100
1 | 1 | 1 | 28µs | 101µs | Test::Deep::HashKeysOnly::::BEGIN@6 Test::Deep::HashKeysOnly::BEGIN@6
3 | 1 | 1 | 17µs | 17µs | Test::Deep::HashKeys::::CORE:sort Test::Deep::HashKeys::CORE:sort (opcode)
3 | 1 | 1 | 15µs | 15µs | Test::Deep::HashKeysOnly::::CORE:sort Test::Deep::HashKeysOnly::CORE:sort (opcode)
0 | 0 | 0 | 0s | 0s | Test::Deep::HashKeysOnly::::diagnostics Test::Deep::HashKeysOnly::diagnostics
0 | 0 | 0 | 0s | 0s | Test::Deep::HashKeysOnly::::ignoreExtra Test::Deep::HashKeysOnly::ignoreExtra
0 | 0 | 0 | 0s | 0s | Test::Deep::HashKeysOnly::::ignoreMissing Test::Deep::HashKeysOnly::ignoreMissing
0 | 0 | 0 | 0s | 0s | Test::Deep::HashKeysOnly::::nice_list Test::Deep::HashKeysOnly::nice_list
0 | 0 | 0 | 0s | 0s | Test::Deep::SubHashKeysOnly::::ignoreExtra Test::Deep::SubHashKeysOnly::ignoreExtra
0 | 0 | 0 | 0s | 0s | Test::Deep::SubHashKeysOnly::::ignoreMissing Test::Deep::SubHashKeysOnly::ignoreMissing
0 | 0 | 0 | 0s | 0s | Test::Deep::SuperHashKeysOnly::::ignoreExtraTest::Deep::SuperHashKeysOnly::ignoreExtra
0 | 0 | 0 | 0s | 0s | Test::Deep::SuperHashKeysOnly::::ignoreMissingTest::Deep::SuperHashKeysOnly::ignoreMissing

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

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 | 2 | 116µs | 2 | 110µs | # spent 93µs (76+17) within Test::Deep::HashKeys::BEGIN@1 which was called: # once (76µs+17µs) by Test::Deep::HashKeys::hashkeysonly at line 1 use strict; # spent 93µs making 1 call to Test::Deep::HashKeys::BEGIN@1 # spent 17µs making 1 call to strict::import
2 | 2 | 128µs | 2 | 102µs | # spent 72µs (43+29) within Test::Deep::HashKeys::BEGIN@2 which was called: # once (43µs+29µs) by Test::Deep::HashKeys::hashkeysonly at line 2 use warnings; # spent 72µs making 1 call to Test::Deep::HashKeys::BEGIN@2 # spent 29µs making 1 call to warnings::import
3 |  |  |  |  |
4 |  |  |  |  | package Test::Deep::HashKeysOnly;
5 |  |  |  |  |
6 | 2 | 1.79ms | 2 | 174µs | # spent 101µs (28+73) within Test::Deep::HashKeysOnly::BEGIN@6 which was called: # once (28µs+73µs) by Test::Deep::HashKeys::hashkeysonly at line 6 use Test::Deep::Ref; # spent 101µs making 1 call to Test::Deep::HashKeysOnly::BEGIN@6 # spent 73µs making 1 call to Test::Deep::Cmp::import
7 |  |  |  |  |
8 |  |  |  |  | sub init
9 |  |  |  |  | # spent 127µs (112+15) within Test::Deep::HashKeysOnly::init which was called 3 times, avg 42µs/call: # 3 times (112µs+15µs) by Test::Deep::Cmp::new at line 33 of Test/Deep/Cmp.pm, avg 42µs/call {
10 | 15 | 141µs |  |  | my $self = shift;
11 |  |  |  |  |
12 |  |  |  |  | my %keys;
13 |  |  |  |  | @keys{@_} = ();
14 |  |  |  |  | $self->{val} = \%keys;
15 |  |  | 3 | 15µs | $self->{keys} = [sort @_]; # spent 15µs making 3 calls to Test::Deep::HashKeysOnly::CORE:sort, avg 5µs/call
16 |  |  |  |  | }
17 |  |  |  |  |
18 |  |  |  |  | sub descend
19 |  |  |  |  | # spent 343µs (229+114) within Test::Deep::HashKeysOnly::descend which was called 3 times, avg 114µs/call: # 3 times (229µs+114µs) by Test::Deep::descend at line 328 of Test/Deep.pm, avg 114µs/call {
20 | 42 | 219µs |  |  | my $self = shift;
21 |  |  |  |  | my $hash = shift;
22 |  |  |  |  |
23 |  |  | 3 | 114µs | my $data = $self->data; # spent 114µs making 3 calls to Test::Deep::Cmp::data, avg 38µs/call
24 |  |  |  |  | my $exp = $self->{val};
25 |  |  |  |  | my %got;
26 |  |  |  |  | @got{keys %$hash} = ();
27 |  |  |  |  |
28 |  |  |  |  | my @missing;
29 |  |  |  |  | my @extra;
30 |  |  |  |  |
31 |  |  |  |  | while (my ($key, $value) = each %$exp)
32 |  |  |  |  | {
33 |  |  |  |  | if (exists $got{$key})
34 |  |  |  |  | {
35 |  |  |  |  | delete $got{$key};
36 |  |  |  |  | }
37 |  |  |  |  | else
38 |  |  |  |  | {
39 |  |  |  |  | push(@missing, $key);
40 |  |  |  |  | }
41 |  |  |  |  | }
42 |  |  |  |  |
43 |  |  |  |  | my @diags;
44 |  |  |  |  | if (@missing and (not $self->ignoreMissing))
45 |  |  |  |  | {
46 |  |  |  |  | push(@diags, "Missing: ".nice_list(\@missing));
47 |  |  |  |  | }
48 |  |  |  |  |
49 |  |  |  |  | if (%got and (not $self->ignoreExtra))
50 |  |  |  |  | {
51 |  |  |  |  | push(@diags, "Extra: ".nice_list([keys %got]));
52 |  |  |  |  | }
53 |  |  |  |  |
54 |  |  |  |  | if (@diags)
55 |  |  |  |  | {
56 |  |  |  |  | $data->{diag} = join("\n", @diags);
57 |  |  |  |  | return 0;
58 |  |  |  |  | }
59 |  |  |  |  |
60 |  |  |  |  | return 1;
61 |  |  |  |  | }
62 |  |  |  |  |
63 |  |  |  |  | sub diagnostics
64 |  |  |  |  | {
65 |  |  |  |  | my $self = shift;
66 |  |  |  |  | my ($where, $last) = @_;
67 |  |  |  |  |
68 |  |  |  |  | my $type = $self->{IgnoreDupes} ? "Set" : "Bag";
69 |  |  |  |  |
70 |  |  |  |  | my $error = $last->{diag};
71 |  |  |  |  | my $diag = <<EOM;
72 |  |  |  |  | Comparing hash keys of $where
73 |  |  |  |  | $error
74 |  |  |  |  | EOM
75 |  |  |  |  |
76 |  |  |  |  | return $diag;
77 |  |  |  |  | }
78 |  |  |  |  |
79 |  |  |  |  | sub nice_list
80 |  |  |  |  | {
81 |  |  |  |  | my $list = shift;
82 |  |  |  |  |
83 |  |  |  |  | return join(", ",
84 |  |  |  |  | (map {"'$_'"} sort @$list),
85 |  |  |  |  | );
86 |  |  |  |  | }
87 |  |  |  |  |
88 |  |  |  |  | sub ignoreMissing
89 |  |  |  |  | {
90 |  |  |  |  | return 0;
91 |  |  |  |  | }
92 |  |  |  |  |
93 |  |  |  |  | sub ignoreExtra
94 |  |  |  |  | {
95 |  |  |  |  | return 0;
96 |  |  |  |  | }
97 |  |  |  |  |
98 |  |  |  |  | package Test::Deep::SuperHashKeysOnly;
99 |  |  |  |  |
100 | 2 | 292µs | 2 | 841µs | # spent 440µs (39+401) within Test::Deep::SuperHashKeysOnly::BEGIN@100 which was called: # once (39µs+401µs) by Test::Deep::HashKeys::hashkeysonly at line 100 use base 'Test::Deep::HashKeysOnly'; # spent 440µs making 1 call to Test::Deep::SuperHashKeysOnly::BEGIN@100 # spent 401µs making 1 call to base::import
101 |  |  |  |  |
102 |  |  |  |  | sub ignoreMissing
103 |  |  |  |  | {
104 |  |  |  |  | return 0;
105 |  |  |  |  | }
106 |  |  |  |  |
107 |  |  |  |  | sub ignoreExtra
108 |  |  |  |  | {
109 |  |  |  |  | return 1;
110 |  |  |  |  | }
111 |  |  |  |  |
112 |  |  |  |  | package Test::Deep::SubHashKeysOnly;
113 |  |  |  |  |
114 | 2 | 241µs | 2 | 530µs | # spent 285µs (40+245) within Test::Deep::SubHashKeysOnly::BEGIN@114 which was called: # once (40µs+245µs) by Test::Deep::HashKeys::hashkeysonly at line 114 use base 'Test::Deep::HashKeysOnly'; # spent 285µs making 1 call to Test::Deep::SubHashKeysOnly::BEGIN@114 # spent 245µs making 1 call to base::import
115 |  |  |  |  |
116 |  |  |  |  | sub ignoreMissing
117 |  |  |  |  | {
118 |  |  |  |  | return 1;
119 |  |  |  |  | }
120 |  |  |  |  |
121 |  |  |  |  | sub ignoreExtra
122 |  |  |  |  | {
123 |  |  |  |  | return 0;
124 |  |  |  |  | }
125 |  |  |  |  |
126 | 1 | 8µs |  |  | 1;
|  |  |  |  | # spent 17µs within Test::Deep::HashKeys::CORE:sort which was called 3 times, avg 6µs/call: # 3 times (17µs+0s) by Test::Deep::HashKeys::init at line 15 of Test/Deep/HashKeys.pm, avg 6µs/call sub Test::Deep::HashKeys::CORE:sort; # opcode
|  |  |  |  | # spent 15µs within Test::Deep::HashKeysOnly::CORE:sort which was called 3 times, avg 5µs/call: # 3 times (15µs+0s) by Test::Deep::HashKeysOnly::init at line 15, avg 5µs/call sub Test::Deep::HashKeysOnly::CORE:sort; # opcode