| Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Test/Deep/Cache.pm |
| Statements | Executed 10 statements in 377µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 401µs | 518µs | Test::Deep::Cache::BEGIN@6 |
| 29 | 1 | 1 | 45µs | 45µs | Test::Deep::CORE:subst (opcode) |
| 1 | 1 | 1 | 12µs | 14µs | Test::Deep::BEGIN@1 |
| 1 | 1 | 1 | 6µs | 14µs | Test::Deep::BEGIN@2 |
| 0 | 0 | 0 | 0s | 0s | Test::Deep::Cache::add |
| 0 | 0 | 0 | 0s | 0s | Test::Deep::Cache::cmp |
| 0 | 0 | 0 | 0s | 0s | Test::Deep::Cache::finish |
| 0 | 0 | 0 | 0s | 0s | Test::Deep::Cache::local |
| 0 | 0 | 0 | 0s | 0s | Test::Deep::Cache::new |
| 0 | 0 | 0 | 0s | 0s | Test::Deep::Cache::type |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | 3 | 16µs | 2 | 16µs | # spent 14µs (12+2) within Test::Deep::BEGIN@1 which was called:
# once (12µs+2µs) by Test::Deep::BEGIN@7 at line 1 # spent 14µs making 1 call to Test::Deep::BEGIN@1
# spent 2µs making 1 call to strict::import |
| 2 | 3 | 28µs | 2 | 22µs | # spent 14µs (6+8) within Test::Deep::BEGIN@2 which was called:
# once (6µs+8µs) by Test::Deep::BEGIN@7 at line 2 # spent 14µs making 1 call to Test::Deep::BEGIN@2
# spent 8µs making 1 call to warnings::import |
| 3 | |||||
| 4 | package Test::Deep::Cache; | ||||
| 5 | |||||
| 6 | 3 | 331µs | 1 | 518µs | # spent 518µs (401+116) within Test::Deep::Cache::BEGIN@6 which was called:
# once (401µs+116µs) by Test::Deep::BEGIN@7 at line 6 # spent 518µs making 1 call to Test::Deep::Cache::BEGIN@6 |
| 7 | |||||
| 8 | sub new | ||||
| 9 | { | ||||
| 10 | my $pkg = shift; | ||||
| 11 | |||||
| 12 | my $self = bless {}, $pkg; | ||||
| 13 | |||||
| 14 | $self->{expects} = [Test::Deep::Cache::Simple->new]; | ||||
| 15 | $self->{normal} = [Test::Deep::Cache::Simple->new]; | ||||
| 16 | |||||
| 17 | $self->local; | ||||
| 18 | |||||
| 19 | return $self; | ||||
| 20 | } | ||||
| 21 | |||||
| 22 | sub add | ||||
| 23 | { | ||||
| 24 | my $self = shift; | ||||
| 25 | |||||
| 26 | my $type = $self->type; | ||||
| 27 | |||||
| 28 | $self->{$type}->[-1]->add(@_); | ||||
| 29 | } | ||||
| 30 | |||||
| 31 | sub cmp | ||||
| 32 | { | ||||
| 33 | # go through all the caches to see if we know this one | ||||
| 34 | |||||
| 35 | my $self = shift; | ||||
| 36 | |||||
| 37 | my $type = $self->type; | ||||
| 38 | |||||
| 39 | foreach my $cache (@{$self->{$type}}) | ||||
| 40 | { | ||||
| 41 | return 1 if $cache->cmp(@_); | ||||
| 42 | } | ||||
| 43 | |||||
| 44 | return 0 | ||||
| 45 | } | ||||
| 46 | |||||
| 47 | sub local | ||||
| 48 | { | ||||
| 49 | my $self = shift; | ||||
| 50 | |||||
| 51 | foreach my $type (qw( expects normal )) | ||||
| 52 | { | ||||
| 53 | push(@{$self->{$type}}, Test::Deep::Cache::Simple->new); | ||||
| 54 | } | ||||
| 55 | } | ||||
| 56 | |||||
| 57 | sub finish | ||||
| 58 | { | ||||
| 59 | my $self = shift; | ||||
| 60 | |||||
| 61 | my $keep = shift; | ||||
| 62 | |||||
| 63 | foreach my $type (qw( expects normal )) | ||||
| 64 | { | ||||
| 65 | my $caches = $self->{$type}; | ||||
| 66 | |||||
| 67 | my $last = pop @$caches; | ||||
| 68 | |||||
| 69 | $caches->[-1]->absorb($last) if $keep; | ||||
| 70 | } | ||||
| 71 | } | ||||
| 72 | |||||
| 73 | sub type | ||||
| 74 | { | ||||
| 75 | return $Test::Deep::Expects ? "expects" : "normal"; | ||||
| 76 | } | ||||
| 77 | |||||
| 78 | 1 | 2µs | 1; | ||
# spent 45µs within Test::Deep::CORE:subst which was called 29 times, avg 2µs/call:
# 29 times (45µs+0s) by main::BEGIN@22 at line 76 of Test/Deep.pm, avg 2µs/call |