Profile of Test/Deep/Cache/Simple.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:00 2012

Filename | /home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Test/Deep/Cache/Simple.pm
Statements | Executed 3467 statements in 32.3ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
324 | 2 | 1 | 10.2ms | 14.8ms | Test::Deep::Cache::Simple::::fn_get_keyTest::Deep::Cache::Simple::fn_get_key
108 | 1 | 1 | 7.03ms | 12.6ms | Test::Deep::Cache::Simple::::addTest::Deep::Cache::Simple::add
216 | 1 | 1 | 4.62ms | 14.8ms | Test::Deep::Cache::Simple::::cmpTest::Deep::Cache::Simple::cmp
324 | 1 | 1 | 2.73ms | 2.73ms | Test::Deep::Cache::Simple::::CORE:sortTest::Deep::Cache::Simple::CORE:sort (opcode)
1 | 1 | 1 | 2.36ms | 3.59ms | Test::Deep::Cache::Simple::::BEGIN@7Test::Deep::Cache::Simple::BEGIN@7
72 | 3 | 1 | 1.39ms | 1.39ms | Test::Deep::Cache::Simple::::newTest::Deep::Cache::Simple::new
1 | 1 | 1 | 57µs | 67µs | Test::Deep::Cache::::BEGIN@1 Test::Deep::Cache::BEGIN@1
1 | 1 | 1 | 39µs | 168µs | Test::Deep::Cache::Simple::::BEGIN@10Test::Deep::Cache::Simple::BEGIN@10
1 | 1 | 1 | 27µs | 45µs | Test::Deep::Cache::::BEGIN@2 Test::Deep::Cache::BEGIN@2
1 | 1 | 1 | 26µs | 140µ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]
0 | 0 | 0 | 0s | 0s | Test::Deep::Cache::Simple::::absorbTest::Deep::Cache::Simple::absorb

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

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 | 2 | 91µs | 2 | 77µs | # spent 67µs (57+10) within Test::Deep::Cache::BEGIN@1 which was called: # once (57µs+10µs) by Test::Deep::Cache::BEGIN@6 at line 1 use strict; # spent 67µs making 1 call to Test::Deep::Cache::BEGIN@1 # spent 10µs making 1 call to strict::import
2 | 2 | 125µs | 2 | 63µs | # spent 45µs (27+18) within Test::Deep::Cache::BEGIN@2 which was called: # once (27µs+18µs) by Test::Deep::Cache::BEGIN@6 at line 2 use warnings; # spent 45µs making 1 call to Test::Deep::Cache::BEGIN@2 # spent 18µs making 1 call to warnings::import
3 |  |  |  |  |
4 |  |  |  |  | package Test::Deep::Cache::Simple;
5 | 2 | 152µs | 2 | 254µs | # spent 140µs (26+114) within Test::Deep::Cache::Simple::BEGIN@5 which was called: # once (26µs+114µs) by Test::Deep::Cache::BEGIN@6 at line 5 use Carp qw( confess ); # spent 140µs making 1 call to Test::Deep::Cache::Simple::BEGIN@5 # spent 114µs making 1 call to Exporter::import
6 |  |  |  |  |
7 | 2 | 950µs | 2 | 3.85ms | # spent 3.59ms (2.36+1.22) within Test::Deep::Cache::Simple::BEGIN@7 which was called: # once (2.36ms+1.22ms) by Test::Deep::Cache::BEGIN@6 at line 7 use Scalar::Util qw( refaddr ); # spent 3.59ms making 1 call to Test::Deep::Cache::Simple::BEGIN@7 # spent 266µs making 1 call to Exporter::import
8 |  |  |  |  |
9 |  |  |  |  | BEGIN
10 |  |  |  |  | # spent 168µs (39+128) within Test::Deep::Cache::Simple::BEGIN@10 which was called: # once (39µs+128µs) by Test::Deep::Cache::BEGIN@6 at line 21 {
11 | 2 | 25µ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 | 128µs | Scalar::Util->import('weaken'); # spent 128µs making 1 call to Exporter::import
20 |  |  |  |  | }
21 | 1 | 1.06ms | 1 | 168µs | } # spent 168µs making 1 call to Test::Deep::Cache::Simple::BEGIN@10
22 |  |  |  |  |
23 |  |  |  |  | sub new
24 |  |  |  |  | # spent 1.39ms within Test::Deep::Cache::Simple::new which was called 72 times, avg 19µs/call: # 36 times (564µs+0s) by Test::Deep::Cache::local at line 53 of Test/Deep/Cache.pm, avg 16µs/call # 18 times (566µs+0s) by Test::Deep::Cache::new at line 14 of Test/Deep/Cache.pm, avg 31µs/call # 18 times (263µs+0s) by Test::Deep::Cache::new at line 15 of Test/Deep/Cache.pm, avg 15µs/call {
25 | 216 | 1.59ms |  |  | my $pkg = shift;
26 |  |  |  |  |
27 |  |  |  |  | my $self = bless {}, $pkg;
28 |  |  |  |  |
29 |  |  |  |  | return $self;
30 |  |  |  |  | }
31 |  |  |  |  |
32 |  |  |  |  | sub add
33 |  |  |  |  | # spent 12.6ms (7.03+5.59) within Test::Deep::Cache::Simple::add which was called 108 times, avg 117µs/call: # 108 times (7.03ms+5.59ms) by Test::Deep::Cache::add at line 28 of Test/Deep/Cache.pm, avg 117µs/call {
34 | 972 | 8.07ms |  |  | my $self = shift;
35 |  |  |  |  |
36 |  |  |  |  | my ($d1, $d2) = @_;
37 |  |  |  |  | {
38 |  |  |  |  | local $SIG{__DIE__};
39 |  |  |  |  |
40 |  |  |  |  | # cannot weaken read only refs, no harm if we can't as they never
41 |  |  |  |  | # disappear
42 |  |  | 108 | 505µs | eval{weaken($d1)}; # spent 505µs making 108 calls to Scalar::Util::weaken, avg 5µs/call
43 |  |  | 108 | 428µs | eval{weaken($d2)}; # spent 428µs making 108 calls to Scalar::Util::weaken, avg 4µs/call
44 |  |  |  |  | }
45 |  |  |  |  |
46 |  |  | 108 | 4.65ms | $self->{fn_get_key(@_)} = [$d1, $d2]; # spent 4.65ms making 108 calls to Test::Deep::Cache::Simple::fn_get_key, avg 43µs/call
47 |  |  |  |  | }
48 |  |  |  |  |
49 |  |  |  |  | sub cmp
50 |  |  |  |  | # spent 14.8ms (4.62+10.2) within Test::Deep::Cache::Simple::cmp which was called 216 times, avg 69µs/call: # 216 times (4.62ms+10.2ms) by Test::Deep::Cache::cmp at line 41 of Test/Deep/Cache.pm, avg 69µs/call {
51 | 1296 | 4.73ms |  |  | my $self = shift;
52 |  |  |  |  |
53 |  |  | 216 | 10.2ms | my $key = fn_get_key(@_); # spent 10.2ms making 216 calls to Test::Deep::Cache::Simple::fn_get_key, avg 47µs/call
54 |  |  |  |  | my $pair = $self->{$key};
55 |  |  |  |  |
56 |  |  |  |  | # are both weakened refs still valid, if not delete this entry
57 |  |  |  |  | if (ref($pair->[0]) and ref($pair->[1]))
58 |  |  |  |  | {
59 |  |  |  |  | return 1;
60 |  |  |  |  | }
61 |  |  |  |  | else
62 |  |  |  |  | {
63 |  |  |  |  | delete $self->{$key};
64 |  |  |  |  | return 0;
65 |  |  |  |  | }
66 |  |  |  |  | }
67 |  |  |  |  |
68 |  |  |  |  | sub absorb
69 |  |  |  |  | {
70 |  |  |  |  | my $self = shift;
71 |  |  |  |  |
72 |  |  |  |  | my $other = shift;
73 |  |  |  |  |
74 |  |  |  |  | @{$self}{keys %$other} = values %$other;
75 |  |  |  |  | }
76 |  |  |  |  |
77 |  |  |  |  | sub fn_get_key
78 |  |  |  |  | # spent 14.8ms (10.2+4.63) within Test::Deep::Cache::Simple::fn_get_key which was called 324 times, avg 46µs/call: # 216 times (6.94ms+3.24ms) by Test::Deep::Cache::Simple::cmp at line 53, avg 47µs/call # 108 times (3.26ms+1.39ms) by Test::Deep::Cache::Simple::add at line 46, avg 43µs/call {
79 | 972 | 15.5ms | 972 | 4.63ms | return join(",", sort (map {refaddr($_)} @_)); # spent 2.73ms making 324 calls to Test::Deep::Cache::Simple::CORE:sort, avg 8µs/call # spent 1.90ms making 648 calls to Scalar::Util::refaddr, avg 3µs/call
80 |  |  |  |  | }
81 | 1 | 10µs |  |  | 1;
|  |  |  |  | # spent 2.73ms within Test::Deep::Cache::Simple::CORE:sort which was called 324 times, avg 8µs/call: # 324 times (2.73ms+0s) by Test::Deep::Cache::Simple::fn_get_key at line 79, avg 8µs/call sub Test::Deep::Cache::Simple::CORE:sort; # opcode