Profile of Test/Deep/Cache/Simple.pm

← 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:05 2015

Filename | /home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/Test/Deep/Cache/Simple.pm
Statements | Executed 587 statements in 1.91ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 724µs | 1.22ms | Test::Deep::Cache::Simple::::BEGIN@7Test::Deep::Cache::Simple::BEGIN@7
54 | 2 | 1 | 537µs | 675µs | Test::Deep::Cache::Simple::::fn_get_keyTest::Deep::Cache::Simple::fn_get_key
40 | 1 | 1 | 263µs | 778µs | Test::Deep::Cache::Simple::::cmpTest::Deep::Cache::Simple::cmp
14 | 1 | 1 | 237µs | 429µs | Test::Deep::Cache::Simple::::addTest::Deep::Cache::Simple::add
54 | 1 | 1 | 72µs | 72µs | Test::Deep::Cache::Simple::::CORE:sortTest::Deep::Cache::Simple::CORE:sort (opcode)
12 | 3 | 1 | 40µs | 40µs | Test::Deep::Cache::Simple::::newTest::Deep::Cache::Simple::new
1 | 1 | 1 | 23µs | 39µs | Test::Deep::Cache::::BEGIN@1 Test::Deep::Cache::BEGIN@1
4 | 1 | 1 | 22µs | 22µs | Test::Deep::Cache::Simple::::absorbTest::Deep::Cache::Simple::absorb
1 | 1 | 1 | 12µs | 38µs | Test::Deep::Cache::Simple::::BEGIN@10Test::Deep::Cache::Simple::BEGIN@10
1 | 1 | 1 | 11µs | 16µs | Test::Deep::Cache::::BEGIN@2 Test::Deep::Cache::BEGIN@2
1 | 1 | 1 | 9µs | 40µs | Test::Deep::Cache::Simple::::BEGIN@5Test::Deep::Cache::Simple::BEGIN@5
0 | 0 | 0 | 0s | 0s | Test::Deep::Cache::Simple::::__ANON__[:15]Test::Deep::Cache::Simple::__ANON__[:15]

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

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 | 2 | 36µs | 2 | 55µs | # spent 39µs (23+16) within Test::Deep::Cache::BEGIN@1 which was called: # once (23µs+16µs) by Test::Deep::Cache::BEGIN@6 at line 1 use strict; # spent 39µs making 1 call to Test::Deep::Cache::BEGIN@1 # spent 16µs making 1 call to strict::import
2 | 2 | 36µs | 2 | 21µs | # spent 16µs (11+5) within Test::Deep::Cache::BEGIN@2 which was called: # once (11µs+5µs) by Test::Deep::Cache::BEGIN@6 at line 2 use warnings; # spent 16µs making 1 call to Test::Deep::Cache::BEGIN@2 # spent 5µs making 1 call to warnings::import
3 |  |  |  |  |
4 |  |  |  |  | package Test::Deep::Cache::Simple;
5 | 2 | 29µs | 2 | 71µs | # spent 40µs (9+31) within Test::Deep::Cache::Simple::BEGIN@5 which was called: # once (9µs+31µs) by Test::Deep::Cache::BEGIN@6 at line 5 use Carp qw( confess ); # spent 40µs making 1 call to Test::Deep::Cache::Simple::BEGIN@5 # spent 31µs making 1 call to Exporter::import
6 |  |  |  |  |
7 | 2 | 200µs | 2 | 1.29ms | # spent 1.22ms (724µs+492µs) within Test::Deep::Cache::Simple::BEGIN@7 which was called: # once (724µs+492µs) by Test::Deep::Cache::BEGIN@6 at line 7 use Scalar::Util qw( refaddr ); # spent 1.22ms making 1 call to Test::Deep::Cache::Simple::BEGIN@7 # spent 72µs making 1 call to Exporter::import
8 |  |  |  |  |
9 |  |  |  |  | BEGIN
10 |  |  |  |  | # spent 38µs (12+27) within Test::Deep::Cache::Simple::BEGIN@10 which was called: # once (12µs+27µs) by Test::Deep::Cache::BEGIN@6 at line 21 {
11 | 1 | 4µs |  |  | if (grep /^weaken$/, @Scalar::Util::EXPORT_FAIL)
12 |  |  |  |  | {
13 |  |  |  |  | # we're running on a version of perl that has no weak refs, so we
14 |  |  |  |  | # just install a no-op sub for weaken instead of importing it
15 |  |  |  |  | *weaken = sub {};
16 |  |  |  |  | }
17 |  |  |  |  | else
18 |  |  |  |  | {
19 | 1 | 3µs | 1 | 27µs | Scalar::Util->import('weaken'); # spent 27µs making 1 call to Exporter::import
20 |  |  |  |  | }
21 | 1 | 256µs | 1 | 38µs | } # spent 38µs making 1 call to Test::Deep::Cache::Simple::BEGIN@10
22 |  |  |  |  |
23 |  |  |  |  | sub new
24 |  |  |  |  | # spent 40µs within Test::Deep::Cache::Simple::new which was called 12 times, avg 3µs/call: # 8 times (22µs+0s) by Test::Deep::Cache::local at line 53 of Test/Deep/Cache.pm, avg 3µs/call # 2 times (14µs+0s) by Test::Deep::Cache::new at line 14 of Test/Deep/Cache.pm, avg 7µs/call # 2 times (5µs+0s) by Test::Deep::Cache::new at line 15 of Test/Deep/Cache.pm, avg 2µs/call {
25 | 12 | 5µs |  |  | my $pkg = shift;
26 |  |  |  |  |
27 | 12 | 20µs |  |  | my $self = bless {}, $pkg;
28 |  |  |  |  |
29 | 12 | 34µs |  |  | return $self;
30 |  |  |  |  | }
31 |  |  |  |  |
32 |  |  |  |  | sub add
33 |  |  |  |  | # spent 429µs (237+191) within Test::Deep::Cache::Simple::add which was called 14 times, avg 31µs/call: # 14 times (237µs+191µs) by Test::Deep::Cache::add at line 28 of Test/Deep/Cache.pm, avg 31µs/call {
34 | 14 | 5µs |  |  | my $self = shift;
35 |  |  |  |  |
36 | 14 | 11µs |  |  | my ($d1, $d2) = @_;
37 |  |  |  |  | {
38 | 28 | 37µs |  |  | local $SIG{__DIE__};
39 |  |  |  |  |
40 |  |  |  |  | # cannot weaken read only refs, no harm if we can't as they never
41 |  |  |  |  | # disappear
42 | 28 | 71µs | 14 | 16µs | eval{weaken($d1)}; # spent 16µs making 14 calls to Scalar::Util::weaken, avg 1µs/call
43 | 28 | 67µs | 14 | 15µs | eval{weaken($d2)}; # spent 15µs making 14 calls to Scalar::Util::weaken, avg 1µs/call
44 |  |  |  |  | }
45 |  |  |  |  |
46 | 14 | 73µs | 14 | 161µs | $self->{fn_get_key(@_)} = [$d1, $d2]; # spent 161µs making 14 calls to Test::Deep::Cache::Simple::fn_get_key, avg 11µs/call
47 |  |  |  |  | }
48 |  |  |  |  |
49 |  |  |  |  | sub cmp
50 |  |  |  |  | # spent 778µs (263+515) within Test::Deep::Cache::Simple::cmp which was called 40 times, avg 19µs/call: # 40 times (263µs+515µs) by Test::Deep::Cache::cmp at line 41 of Test/Deep/Cache.pm, avg 19µs/call {
51 | 40 | 12µs |  |  | my $self = shift;
52 |  |  |  |  |
53 | 40 | 65µs | 40 | 515µs | my $key = fn_get_key(@_); # spent 515µs making 40 calls to Test::Deep::Cache::Simple::fn_get_key, avg 13µs/call
54 | 40 | 22µs |  |  | my $pair = $self->{$key};
55 |  |  |  |  |
56 |  |  |  |  | # are both weakened refs still valid, if not delete this entry
57 | 40 | 28µs |  |  | if (ref($pair->[0]) and ref($pair->[1]))
58 |  |  |  |  | {
59 |  |  |  |  | return 1;
60 |  |  |  |  | }
61 |  |  |  |  | else
62 |  |  |  |  | {
63 | 40 | 19µs |  |  | delete $self->{$key};
64 | 40 | 104µs |  |  | return 0;
65 |  |  |  |  | }
66 |  |  |  |  | }
67 |  |  |  |  |
68 |  |  |  |  | sub absorb
69 |  |  |  |  | # spent 22µs within Test::Deep::Cache::Simple::absorb which was called 4 times, avg 5µs/call: # 4 times (22µs+0s) by Test::Deep::Cache::finish at line 69 of Test/Deep/Cache.pm, avg 5µs/call {
70 | 4 | 2µs |  |  | my $self = shift;
71 |  |  |  |  |
72 | 4 | 1µs |  |  | my $other = shift;
73 |  |  |  |  |
74 | 4 | 30µs |  |  | @{$self}{keys %$other} = values %$other;
75 |  |  |  |  | }
76 |  |  |  |  |
77 |  |  |  |  | sub fn_get_key
78 |  |  |  |  | # spent 675µs (537+138) within Test::Deep::Cache::Simple::fn_get_key which was called 54 times, avg 13µs/call: # 40 times (407µs+108µs) by Test::Deep::Cache::Simple::cmp at line 53, avg 13µs/call # 14 times (130µs+31µs) by Test::Deep::Cache::Simple::add at line 46, avg 11µs/call {
79 | 162 | 742µs | 162 | 138µs | return join(",", sort (map {refaddr($_)} @_)); # spent 72µs making 54 calls to Test::Deep::Cache::Simple::CORE:sort, avg 1µs/call # spent 66µs making 108 calls to Scalar::Util::refaddr, avg 612ns/call
80 |  |  |  |  | }
81 | 1 | 2µs |  |  | 1;
|  |  |  |  | # spent 72µs within Test::Deep::Cache::Simple::CORE:sort which was called 54 times, avg 1µs/call: # 54 times (72µs+0s) by Test::Deep::Cache::Simple::fn_get_key at line 79, avg 1µs/call sub Test::Deep::Cache::Simple::CORE:sort; # opcode