Filename | /homes/dcw/lib/perl5/DCW/Sorthash.pm |
Statements | Executed 241 statements in 1.77ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
57 | 2 | 1 | 1.13ms | 1.38ms | as_string | Sorthash::
57 | 1 | 1 | 249µs | 249µs | CORE:sort (opcode) | Sorthash::
1 | 1 | 1 | 32µs | 32µs | BEGIN@8 | Sorthash::
1 | 1 | 1 | 26µs | 26µs | new | Sorthash::
1 | 1 | 1 | 18µs | 21µs | BEGIN@6 | Sorthash::
1 | 1 | 1 | 11µs | 41µs | BEGIN@11 | Sorthash::
1 | 1 | 1 | 8µs | 41µs | BEGIN@8.4 | Sorthash::
1 | 1 | 1 | 7µs | 16µs | BEGIN@7 | Sorthash::
0 | 0 | 0 | 0s | 0s | keys | Sorthash::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Sorthash; | ||||
2 | |||||
3 | # an OO perl wrapper around a hashref, | ||||
4 | # that sorts it's keys when printing.. | ||||
5 | |||||
6 | 2 | 27µs | 2 | 24µs | # spent 21µs (18+3) within Sorthash::BEGIN@6 which was called:
# once (18µs+3µs) by NewBoard::BEGIN@26 at line 6 # spent 21µs making 1 call to Sorthash::BEGIN@6
# spent 3µs making 1 call to strict::import |
7 | 2 | 28µs | 2 | 26µs | # spent 16µs (7+9) within Sorthash::BEGIN@7 which was called:
# once (7µs+9µs) by NewBoard::BEGIN@26 at line 7 # spent 16µs making 1 call to Sorthash::BEGIN@7
# spent 9µs making 1 call to warnings::import |
8 | 4 | 107µs | 3 | 106µs | use v5.10; # spent 41µs making 1 call to Sorthash::BEGIN@8.4
# spent 33µs making 1 call to feature::import
# spent 32µs making 1 call to Sorthash::BEGIN@8 |
9 | #use Function::Parameters; | ||||
10 | |||||
11 | 2 | 226µs | 2 | 70µs | # spent 41µs (11+30) within Sorthash::BEGIN@11 which was called:
# once (11µs+30µs) by NewBoard::BEGIN@26 at line 11 # spent 41µs making 1 call to Sorthash::BEGIN@11
# spent 30µs making 1 call to overload::import |
12 | |||||
13 | |||||
14 | sub new | ||||
15 | # spent 26µs within Sorthash::new which was called:
# once (26µs+0s) by NewBoard::mkboard at line 99 of NewBoard.pm | ||||
16 | 1 | 1µs | my($class, %hash ) = @_; | ||
17 | 1 | 27µs | return bless { %hash }, $class; | ||
18 | } | ||||
19 | |||||
20 | |||||
21 | sub as_string | ||||
22 | # spent 1.38ms (1.13+249µs) within Sorthash::as_string which was called 57 times, avg 24µs/call:
# 56 times (1.12ms+248µs) by main::solve_game at line 33 of NewSolveGame.pm, avg 24µs/call
# once (4µs+800ns) by main::solve_game at line 44 of NewSolveGame.pm | ||||
23 | 57 | 43µs | my $self = shift; | ||
24 | 57 | 949µs | 57 | 249µs | my @k = map { "$_ -> $self->{$_}" } sort keys %$self; # spent 249µs making 57 calls to Sorthash::CORE:sort, avg 4µs/call |
25 | 57 | 47µs | local $" = ', '; | ||
26 | 57 | 315µs | return "@k"; | ||
27 | }; | ||||
28 | |||||
29 | |||||
30 | sub keys | ||||
31 | { | ||||
32 | my $self = shift; | ||||
33 | my @k = sort keys %$self; | ||||
34 | return @k; | ||||
35 | }; | ||||
36 | |||||
37 | |||||
38 | 1 | 3µs | 1; | ||
# spent 249µs within Sorthash::CORE:sort which was called 57 times, avg 4µs/call:
# 57 times (249µs+0s) by Sorthash::as_string at line 24, avg 4µs/call |