← Index
NYTProf Performance Profile   « line view »
For t/optimization.t
  Run on Thu Jan 8 22:47:42 2015
Reported on Thu Jan 8 22:48:06 2015

Filename/home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/Test/Deep/HashKeysOnly.pm
StatementsExecuted 49 statements in 1.01ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
21167µs83µsTest::Deep::HashKeysOnly::::descend Test::Deep::HashKeysOnly::descend
21143µs54µsTest::Deep::HashKeysOnly::::init Test::Deep::HashKeysOnly::init
11122µs146µsTest::Deep::SuperHashKeysOnly::::BEGIN@100Test::Deep::SuperHashKeysOnly::BEGIN@100
11120µs41µsTest::Deep::HashKeys::::BEGIN@1 Test::Deep::HashKeys::BEGIN@1
11119µs135µsTest::Deep::SubHashKeysOnly::::BEGIN@114 Test::Deep::SubHashKeysOnly::BEGIN@114
11117µs24µsTest::Deep::HashKeys::::BEGIN@2 Test::Deep::HashKeys::BEGIN@2
11115µs40µsTest::Deep::HashKeysOnly::::BEGIN@6 Test::Deep::HashKeysOnly::BEGIN@6
21111µs11µsTest::Deep::HashKeysOnly::::CORE:sort Test::Deep::HashKeysOnly::CORE:sort (opcode)
0000s0sTest::Deep::HashKeysOnly::::diagnostics Test::Deep::HashKeysOnly::diagnostics
0000s0sTest::Deep::HashKeysOnly::::ignoreExtra Test::Deep::HashKeysOnly::ignoreExtra
0000s0sTest::Deep::HashKeysOnly::::ignoreMissing Test::Deep::HashKeysOnly::ignoreMissing
0000s0sTest::Deep::HashKeysOnly::::nice_list Test::Deep::HashKeysOnly::nice_list
0000s0sTest::Deep::SubHashKeysOnly::::ignoreExtra Test::Deep::SubHashKeysOnly::ignoreExtra
0000s0sTest::Deep::SubHashKeysOnly::::ignoreMissing Test::Deep::SubHashKeysOnly::ignoreMissing
0000s0sTest::Deep::SuperHashKeysOnly::::ignoreExtraTest::Deep::SuperHashKeysOnly::ignoreExtra
0000s0sTest::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
1250µs263µs
# spent 41µs (20+21) within Test::Deep::HashKeys::BEGIN@1 which was called: # once (20µs+21µs) by Test::Deep::HashKeys::hashkeysonly at line 1
use strict;
# spent 41µs making 1 call to Test::Deep::HashKeys::BEGIN@1 # spent 22µs making 1 call to strict::import
2264µs230µs
# spent 24µs (17+7) within Test::Deep::HashKeys::BEGIN@2 which was called: # once (17µs+7µs) by Test::Deep::HashKeys::hashkeysonly at line 2
use warnings;
# spent 24µs making 1 call to Test::Deep::HashKeys::BEGIN@2 # spent 7µs making 1 call to warnings::import
3
4package Test::Deep::HashKeysOnly;
5
62554µs266µs
# spent 40µs (15+25) within Test::Deep::HashKeysOnly::BEGIN@6 which was called: # once (15µs+25µs) by Test::Deep::HashKeys::hashkeysonly at line 6
use Test::Deep::Ref;
# spent 40µs making 1 call to Test::Deep::HashKeysOnly::BEGIN@6 # spent 25µs making 1 call to Test::Deep::Cmp::import
7
8sub init
9
# spent 54µs (43+11) within Test::Deep::HashKeysOnly::init which was called 2 times, avg 27µs/call: # 2 times (43µs+11µs) by Test::Deep::Cmp::new at line 33 of Test/Deep/Cmp.pm, avg 27µs/call
{
1021µs my $self = shift;
11
122900ns my %keys;
1329µs @keys{@_} = ();
1424µs $self->{val} = \%keys;
15242µs211µs $self->{keys} = [sort @_];
# spent 11µs making 2 calls to Test::Deep::HashKeysOnly::CORE:sort, avg 5µs/call
16}
17
18sub descend
19
# spent 83µs (67+17) within Test::Deep::HashKeysOnly::descend which was called 2 times, avg 42µs/call: # 2 times (67µs+17µs) by Test::Deep::descend at line 344 of Test/Deep.pm, avg 42µs/call
{
202900ns my $self = shift;
212700ns my $hash = shift;
22
2327µs217µs my $data = $self->data;
# spent 17µs making 2 calls to Test::Deep::Cmp::data, avg 8µs/call
2421µs my $exp = $self->{val};
252500ns my %got;
26210µs @got{keys %$hash} = ();
27
282500ns my @missing;
292400ns my @extra;
30
31232µs 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
432500ns my @diags;
442800ns if (@missing and (not $self->ignoreMissing))
45 {
46 push(@diags, "Missing: ".nice_list(\@missing));
47 }
48
492900ns if (%got and (not $self->ignoreExtra))
50 {
51 push(@diags, "Extra: ".nice_list([keys %got]));
52 }
53
542500ns if (@diags)
55 {
56 $data->{diag} = join("\n", @diags);
57 return 0;
58 }
59
6029µs return 1;
61}
62
63sub 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;
72Comparing hash keys of $where
73$error
74EOM
75
76 return $diag;
77}
78
79sub nice_list
80{
81 my $list = shift;
82
83 return join(", ",
84 (map {"'$_'"} sort @$list),
85 );
86}
87
88sub ignoreMissing
89{
90 return 0;
91}
92
93sub ignoreExtra
94{
95 return 0;
96}
97
98package Test::Deep::SuperHashKeysOnly;
99
1002124µs2271µs
# spent 146µs (22+125) within Test::Deep::SuperHashKeysOnly::BEGIN@100 which was called: # once (22µs+125µs) by Test::Deep::HashKeys::hashkeysonly at line 100
use base 'Test::Deep::HashKeysOnly';
# spent 146µs making 1 call to Test::Deep::SuperHashKeysOnly::BEGIN@100 # spent 125µs making 1 call to base::import
101
102sub ignoreMissing
103{
104 return 0;
105}
106
107sub ignoreExtra
108{
109 return 1;
110}
111
112package Test::Deep::SubHashKeysOnly;
113
114291µs2251µs
# spent 135µs (19+116) within Test::Deep::SubHashKeysOnly::BEGIN@114 which was called: # once (19µs+116µs) by Test::Deep::HashKeys::hashkeysonly at line 114
use base 'Test::Deep::HashKeysOnly';
# spent 135µs making 1 call to Test::Deep::SubHashKeysOnly::BEGIN@114 # spent 116µs making 1 call to base::import
115
116sub ignoreMissing
117{
118 return 1;
119}
120
121sub ignoreExtra
122{
123 return 0;
124}
125
12614µs1;
 
# spent 11µs within Test::Deep::HashKeysOnly::CORE:sort which was called 2 times, avg 5µs/call: # 2 times (11µs+0s) by Test::Deep::HashKeysOnly::init at line 15, avg 5µs/call
sub Test::Deep::HashKeysOnly::CORE:sort; # opcode