| File | /usr/local/lib/perl5/5.10.1/Test/Deep/HashKeysOnly.pm |
| Statements Executed | 54 |
| Statement Execution Time | 615µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 2 | 1 | 1 | 37µs | 56µs | Test::Deep::HashKeysOnly::descend |
| 2 | 1 | 1 | 20µs | 23µs | Test::Deep::HashKeysOnly::init |
| 1 | 1 | 1 | 18µs | 22µs | Test::Deep::HashKeys::BEGIN@1 |
| 1 | 1 | 1 | 9µs | 20µs | Test::Deep::HashKeys::BEGIN@2 |
| 1 | 1 | 1 | 9µs | 97µs | Test::Deep::SuperHashKeysOnly::BEGIN@100 |
| 1 | 1 | 1 | 9µs | 54µs | Test::Deep::SubHashKeysOnly::BEGIN@114 |
| 1 | 1 | 1 | 7µs | 21µs | Test::Deep::HashKeysOnly::BEGIN@6 |
| 2 | 1 | 2 | 3µs | 3µs | Test::Deep::HashKeysOnly::CORE:sort (opcode) |
| 0 | 0 | 0 | 0s | 0s | Test::Deep::HashKeysOnly::diagnostics |
| 0 | 0 | 0 | 0s | 0s | Test::Deep::HashKeysOnly::ignoreExtra |
| 0 | 0 | 0 | 0s | 0s | Test::Deep::HashKeysOnly::ignoreMissing |
| 0 | 0 | 0 | 0s | 0s | Test::Deep::HashKeysOnly::nice_list |
| 0 | 0 | 0 | 0s | 0s | Test::Deep::SubHashKeysOnly::ignoreExtra |
| 0 | 0 | 0 | 0s | 0s | Test::Deep::SubHashKeysOnly::ignoreMissing |
| 0 | 0 | 0 | 0s | 0s | Test::Deep::SuperHashKeysOnly::ignoreExtra |
| 0 | 0 | 0 | 0s | 0s | Test::Deep::SuperHashKeysOnly::ignoreMissing |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | 3 | 32µs | 2 | 26µs | # spent 22µs (18+4) within Test::Deep::HashKeys::BEGIN@1 which was called
# once (18µs+4µs) by Test::Deep::HashKeys::hashkeysonly at line 1 # spent 22µs making 1 call to Test::Deep::HashKeys::BEGIN@1
# spent 4µs making 1 call to strict::import |
| 2 | 3 | 29µs | 2 | 32µs | # spent 20µs (9+12) within Test::Deep::HashKeys::BEGIN@2 which was called
# once (9µs+12µs) by Test::Deep::HashKeys::hashkeysonly at line 2 # spent 20µs making 1 call to Test::Deep::HashKeys::BEGIN@2
# spent 12µs making 1 call to warnings::import |
| 3 | |||||
| 4 | package Test::Deep::HashKeysOnly; | ||||
| 5 | |||||
| 6 | 3 | 356µs | 2 | 35µs | # spent 21µs (7+14) within Test::Deep::HashKeysOnly::BEGIN@6 which was called
# once (7µs+14µs) by Test::Deep::HashKeys::hashkeysonly at line 6 # spent 21µs making 1 call to Test::Deep::HashKeysOnly::BEGIN@6
# spent 14µs making 1 call to Test::Deep::Cmp::import |
| 7 | |||||
| 8 | sub init | ||||
| 9 | # spent 23µs (20+3) within Test::Deep::HashKeysOnly::init which was called 2 times, avg 12µs/call:
# 2 times (20µs+3µs) by Test::Deep::Cmp::new at line 32 of Test/Deep/Cmp.pm, avg 12µs/call | ||||
| 10 | 2 | 300ns | my $self = shift; | ||
| 11 | |||||
| 12 | 2 | 300ns | my %keys; | ||
| 13 | 2 | 3µs | @keys{@_} = (); | ||
| 14 | 2 | 2µs | $self->{val} = \%keys; | ||
| 15 | 2 | 18µs | 2 | 3µs | $self->{keys} = [sort @_]; # spent 3µs making 2 calls to Test::Deep::HashKeysOnly::CORE:sort, avg 1µs/call |
| 16 | } | ||||
| 17 | |||||
| 18 | sub descend | ||||
| 19 | # spent 56µs (37+19) within Test::Deep::HashKeysOnly::descend which was called 2 times, avg 28µs/call:
# 2 times (37µs+19µs) by Test::Deep::descend at line 312 of Test/Deep.pm, avg 28µs/call | ||||
| 20 | 2 | 500ns | my $self = shift; | ||
| 21 | 2 | 400ns | my $hash = shift; | ||
| 22 | |||||
| 23 | 2 | 5µs | 2 | 19µs | my $data = $self->data; # spent 19µs making 2 calls to Test::Deep::Cmp::data, avg 9µs/call |
| 24 | 2 | 900ns | my $exp = $self->{val}; | ||
| 25 | 2 | 300ns | my %got; | ||
| 26 | 2 | 5µs | @got{keys %$hash} = (); | ||
| 27 | |||||
| 28 | 2 | 400ns | my @missing; | ||
| 29 | 2 | 100ns | my @extra; | ||
| 30 | |||||
| 31 | 2 | 14µ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 | |||||
| 43 | 2 | 100ns | my @diags; | ||
| 44 | 2 | 500ns | if (@missing and (not $self->ignoreMissing)) | ||
| 45 | { | ||||
| 46 | push(@diags, "Missing: ".nice_list(\@missing)); | ||||
| 47 | } | ||||
| 48 | |||||
| 49 | 2 | 400ns | if (%got and (not $self->ignoreExtra)) | ||
| 50 | { | ||||
| 51 | push(@diags, "Extra: ".nice_list([keys %got])); | ||||
| 52 | } | ||||
| 53 | |||||
| 54 | 2 | 200ns | if (@diags) | ||
| 55 | { | ||||
| 56 | $data->{diag} = join("\n", @diags); | ||||
| 57 | return 0; | ||||
| 58 | } | ||||
| 59 | |||||
| 60 | 2 | 6µs | return 1; | ||
| 61 | } | ||||
| 62 | |||||
| 63 | sub 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; | ||||
| 72 | Comparing hash keys of $where | ||||
| 73 | $error | ||||
| 74 | EOM | ||||
| 75 | |||||
| 76 | return $diag; | ||||
| 77 | } | ||||
| 78 | |||||
| 79 | sub nice_list | ||||
| 80 | { | ||||
| 81 | my $list = shift; | ||||
| 82 | |||||
| 83 | return join(", ", | ||||
| 84 | (map {"'$_'"} sort @$list), | ||||
| 85 | ); | ||||
| 86 | } | ||||
| 87 | |||||
| 88 | sub ignoreMissing | ||||
| 89 | { | ||||
| 90 | return 0; | ||||
| 91 | } | ||||
| 92 | |||||
| 93 | sub ignoreExtra | ||||
| 94 | { | ||||
| 95 | return 0; | ||||
| 96 | } | ||||
| 97 | |||||
| 98 | package Test::Deep::SuperHashKeysOnly; | ||||
| 99 | |||||
| 100 | 3 | 74µs | 2 | 185µs | # spent 97µs (9+88) within Test::Deep::SuperHashKeysOnly::BEGIN@100 which was called
# once (9µs+88µs) by Test::Deep::HashKeys::hashkeysonly at line 100 # spent 97µs making 1 call to Test::Deep::SuperHashKeysOnly::BEGIN@100
# spent 88µs making 1 call to base::import |
| 101 | |||||
| 102 | sub ignoreMissing | ||||
| 103 | { | ||||
| 104 | return 0; | ||||
| 105 | } | ||||
| 106 | |||||
| 107 | sub ignoreExtra | ||||
| 108 | { | ||||
| 109 | return 1; | ||||
| 110 | } | ||||
| 111 | |||||
| 112 | package Test::Deep::SubHashKeysOnly; | ||||
| 113 | |||||
| 114 | 3 | 64µs | 2 | 100µs | # spent 54µs (9+46) within Test::Deep::SubHashKeysOnly::BEGIN@114 which was called
# once (9µs+46µs) by Test::Deep::HashKeys::hashkeysonly at line 114 # spent 54µs making 1 call to Test::Deep::SubHashKeysOnly::BEGIN@114
# spent 46µs making 1 call to base::import |
| 115 | |||||
| 116 | sub ignoreMissing | ||||
| 117 | { | ||||
| 118 | return 1; | ||||
| 119 | } | ||||
| 120 | |||||
| 121 | sub ignoreExtra | ||||
| 122 | { | ||||
| 123 | return 0; | ||||
| 124 | } | ||||
| 125 | |||||
| 126 | 1 | 3µs | 1; | ||
# spent 3µs within Test::Deep::HashKeysOnly::CORE:sort which was called 2 times, avg 1µs/call:
# 2 times (3µs+0s) by Test::Deep::HashKeysOnly::init at line 15 of Test/Deep/HashKeysOnly.pm, avg 1µs/call |