File | /usr/local/lib/perl5/5.10.1/Test/Deep/Cache/Simple.pm |
Statements Executed | 598 |
Statement Execution Time | 1.53ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 663µs | 1.78ms | BEGIN@7 | Test::Deep::Cache::Simple::
57 | 2 | 1 | 437µs | 556µs | fn_get_key | Test::Deep::Cache::Simple::
19 | 1 | 1 | 286µs | 509µs | add | Test::Deep::Cache::Simple::
38 | 1 | 1 | 205µs | 582µs | cmp | Test::Deep::Cache::Simple::
57 | 1 | 2 | 67µs | 67µs | CORE:sort (opcode) | Test::Deep::Cache::Simple::
4 | 3 | 1 | 20µs | 20µs | new | Test::Deep::Cache::Simple::
1 | 1 | 1 | 13µs | 15µs | BEGIN@1 | Test::Deep::Cache::
1 | 1 | 1 | 8µs | 30µs | BEGIN@10 | Test::Deep::Cache::Simple::
1 | 1 | 1 | 7µs | 15µs | BEGIN@2 | Test::Deep::Cache::
1 | 1 | 1 | 6µs | 30µs | BEGIN@5 | Test::Deep::Cache::Simple::
0 | 0 | 0 | 0s | 0s | __ANON__[:15] | Test::Deep::Cache::Simple::
0 | 0 | 0 | 0s | 0s | absorb | Test::Deep::Cache::Simple::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | 3 | 19µs | 2 | 18µs | # spent 15µs (13+3) within Test::Deep::Cache::BEGIN@1 which was called
# once (13µs+3µs) by Test::Deep::Cache::BEGIN@6 at line 1 # spent 15µs making 1 call to Test::Deep::Cache::BEGIN@1
# spent 3µs making 1 call to strict::import |
2 | 3 | 26µs | 2 | 24µs | # spent 15µs (7+9) within Test::Deep::Cache::BEGIN@2 which was called
# once (7µs+9µs) by Test::Deep::Cache::BEGIN@6 at line 2 # spent 15µs making 1 call to Test::Deep::Cache::BEGIN@2
# spent 8µs making 1 call to warnings::import |
3 | |||||
4 | package Test::Deep::Cache::Simple; | ||||
5 | 3 | 28µs | 2 | 54µs | # spent 30µs (6+24) within Test::Deep::Cache::Simple::BEGIN@5 which was called
# once (6µs+24µs) by Test::Deep::Cache::BEGIN@6 at line 5 # spent 30µs making 1 call to Test::Deep::Cache::Simple::BEGIN@5
# spent 24µs making 1 call to Exporter::import |
6 | |||||
7 | 3 | 133µs | 2 | 1.84ms | # spent 1.78ms (663µs+1.12) within Test::Deep::Cache::Simple::BEGIN@7 which was called
# once (663µs+1.12ms) by Test::Deep::Cache::BEGIN@6 at line 7 # spent 1.78ms making 1 call to Test::Deep::Cache::Simple::BEGIN@7
# spent 53µs making 1 call to Exporter::import |
8 | |||||
9 | BEGIN | ||||
10 | # spent 30µs (8+22) within Test::Deep::Cache::Simple::BEGIN@10 which was called
# once (8µs+22µs) by Test::Deep::Cache::BEGIN@6 at line 21 | ||||
11 | 2 | 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 | Scalar::Util->import('weaken'); # spent 22µs making 1 call to Exporter::import | ||||
20 | } | ||||
21 | 1 | 216µs | 1 | 30µs | } # spent 30µs making 1 call to Test::Deep::Cache::Simple::BEGIN@10 |
22 | |||||
23 | sub new | ||||
24 | # spent 20µs within Test::Deep::Cache::Simple::new which was called 4 times, avg 5µs/call:
# 2 times (6µs+0s) by Test::Deep::Cache::local at line 53 of Test/Deep/Cache.pm, avg 3µs/call
# once (11µs+0s) by Test::Deep::Cache::new at line 14 of Test/Deep/Cache.pm
# once (3µs+0s) by Test::Deep::Cache::new at line 15 of Test/Deep/Cache.pm | ||||
25 | 12 | 38µs | my $pkg = shift; | ||
26 | |||||
27 | my $self = bless {}, $pkg; | ||||
28 | |||||
29 | return $self; | ||||
30 | } | ||||
31 | |||||
32 | sub add | ||||
33 | # spent 509µs (286+223) within Test::Deep::Cache::Simple::add which was called 19 times, avg 27µs/call:
# 19 times (286µs+223µs) by Test::Deep::Cache::add at line 28 of Test/Deep/Cache.pm, avg 27µs/call | ||||
34 | 76 | 103µs | my $self = shift; | ||
35 | |||||
36 | my ($d1, $d2) = @_; | ||||
37 | { | ||||
38 | 57 | 75µs | local $SIG{__DIE__}; | ||
39 | |||||
40 | # cannot weaken read only refs, no harm if we can't as they never | ||||
41 | # disappear | ||||
42 | 19 | 71µs | 19 | 19µs | eval{weaken($d1)}; # spent 19µs making 19 calls to Scalar::Util::weaken, avg 989ns/call |
43 | 19 | 59µs | 19 | 25µs | eval{weaken($d2)}; # spent 25µs making 19 calls to Scalar::Util::weaken, avg 1µs/call |
44 | } | ||||
45 | |||||
46 | $self->{fn_get_key(@_)} = [$d1, $d2]; # spent 179µs making 19 calls to Test::Deep::Cache::Simple::fn_get_key, avg 9µs/call | ||||
47 | } | ||||
48 | |||||
49 | sub cmp | ||||
50 | # spent 582µs (205+378) within Test::Deep::Cache::Simple::cmp which was called 38 times, avg 15µs/call:
# 38 times (205µs+378µs) by Test::Deep::Cache::cmp at line 41 of Test/Deep/Cache.pm, avg 15µs/call | ||||
51 | 152 | 96µs | my $self = shift; | ||
52 | |||||
53 | my $key = fn_get_key(@_); # spent 378µs making 38 calls to Test::Deep::Cache::Simple::fn_get_key, avg 10µs/call | ||||
54 | my $pair = $self->{$key}; | ||||
55 | |||||
56 | # are both weakened refs still valid, if not delete this entry | ||||
57 | 76 | 92µs | 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 | { | ||||
79 | 171 | 570µs | 171 | 120µs | return join(",", sort (map {refaddr($_)} @_)); # spent 67µs making 57 calls to Test::Deep::Cache::Simple::CORE:sort, avg 1µs/call
# spent 53µs making 114 calls to Scalar::Util::refaddr, avg 461ns/call |
80 | } | ||||
81 | 1 | 2µs | 1; | ||
# spent 67µs within Test::Deep::Cache::Simple::CORE:sort which was called 57 times, avg 1µs/call:
# 57 times (67µs+0s) by Test::Deep::Cache::Simple::fn_get_key at line 79 of Test/Deep/Cache/Simple.pm, avg 1µs/call |