| Filename | /homes/dcw/src/perl/coloroids_solver/NewSolveGame.pm |
| Statements | Executed 475 statements in 9.75ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 2.94ms | 58.1s | main::solve_game |
| 1 | 1 | 1 | 14µs | 14µs | main::BEGIN@5 |
| 1 | 1 | 1 | 5µs | 90µs | main::BEGIN@6 |
| 1 | 1 | 1 | 5µs | 28µs | main::BEGIN@5.8 |
| 1 | 1 | 1 | 5µs | 20µs | main::BEGIN@7.9 |
| 1 | 1 | 1 | 5µs | 20µs | main::BEGIN@10.11 |
| 1 | 1 | 1 | 5µs | 38µs | main::BEGIN@9.10 |
| 1 | 1 | 1 | 4µs | 13µs | main::BEGIN@14.13 |
| 1 | 1 | 1 | 4µs | 17µs | main::BEGIN@11 |
| 1 | 1 | 1 | 3µs | 3µs | main::BEGIN@12.12 |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | # | ||||
| 2 | # NewSolveGame: solve coloroid using NewBoard and pickbest helper function. | ||||
| 3 | # | ||||
| 4 | |||||
| 5 | 4 | 50µs | 3 | 64µs | use v5.12; # spent 28µs making 1 call to main::BEGIN@5.8
# spent 22µs making 1 call to feature::import
# spent 14µs making 1 call to main::BEGIN@5 |
| 6 | 2 | 19µs | 2 | 175µs | # spent 90µs (5+85) within main::BEGIN@6 which was called:
# once (5µs+85µs) by main::BEGIN@14.7 at line 6 # spent 90µs making 1 call to main::BEGIN@6
# spent 85µs making 1 call to Function::Parameters::import |
| 7 | 2 | 19µs | 2 | 36µs | # spent 20µs (5+16) within main::BEGIN@7.9 which was called:
# once (5µs+16µs) by main::BEGIN@14.7 at line 7 # spent 20µs making 1 call to main::BEGIN@7.9
# spent 16µs making 1 call to Exporter::import |
| 8 | |||||
| 9 | 2 | 19µs | 2 | 70µs | # spent 38µs (5+33) within main::BEGIN@9.10 which was called:
# once (5µs+33µs) by main::BEGIN@14.7 at line 9 # spent 38µs making 1 call to main::BEGIN@9.10
# spent 33µs making 1 call to lib::import |
| 10 | 2 | 17µs | 2 | 34µs | # spent 20µs (5+15) within main::BEGIN@10.11 which was called:
# once (5µs+15µs) by main::BEGIN@14.7 at line 10 # spent 20µs making 1 call to main::BEGIN@10.11
# spent 15µs making 1 call to Exporter::import |
| 11 | 2 | 15µs | 2 | 30µs | # spent 17µs (4+13) within main::BEGIN@11 which was called:
# once (4µs+13µs) by main::BEGIN@14.7 at line 11 # spent 17µs making 1 call to main::BEGIN@11
# spent 13µs making 1 call to Exporter::import |
| 12 | 2 | 15µs | 1 | 3µs | # spent 3µs within main::BEGIN@12.12 which was called:
# once (3µs+0s) by main::BEGIN@14.7 at line 12 # spent 3µs making 1 call to main::BEGIN@12.12 |
| 13 | |||||
| 14 | 2 | 163µs | 2 | 22µs | # spent 13µs (4+9) within main::BEGIN@14.13 which was called:
# once (4µs+9µs) by main::BEGIN@14.7 at line 14 # spent 13µs making 1 call to main::BEGIN@14.13
# spent 9µs making 1 call to Exporter::import |
| 15 | |||||
| 16 | |||||
| 17 | # | ||||
| 18 | # my $nmoves = solve_game( $board, $pickbest, optional $postmove ); | ||||
| 19 | # Play a complete game, given $board and a picker | ||||
| 20 | # function $pickbest. Each move we call $pickbest | ||||
| 21 | # to pick the best single move, make that move and | ||||
| 22 | # then call the $postmove callback. return the | ||||
| 23 | # number of moves taken to finish. | ||||
| 24 | # | ||||
| 25 | # spent 58.1s (2.94ms+58.1) within main::solve_game which was called:
# once (2.94ms+58.1s) by main::RUNTIME at line 45 of testnewboardincnply | ||||
| 26 | 8 | 471µs | { | ||
| 27 | # for each move | ||||
| 28 | my $moves; | ||||
| 29 | 448 | 1.55ms | 57 | 557µs | for( $moves=1; ! $board->solved; $moves++ ) # spent 557µs making 57 calls to NewBoard::solved, avg 10µs/call |
| 30 | { | ||||
| 31 | 56 | 153µs | my( $nregion, $adjcolbag ) = $board->region; # spent 153µs making 56 calls to NewBoard::region, avg 3µs/call | ||
| 32 | 1 | 6.76ms | 112 | 171ms | print "\nmove $moves: board=\n$board\n"; # spent 165ms making 56 calls to NewBoard::as_string, avg 2.94ms/call
# spent 6.46ms making 56 calls to main::CORE:print, avg 115µs/call |
| 33 | 1 | 530µs | 112 | 1.76ms | print " adjcolbag = $adjcolbag, nregion=$nregion\n"; # spent 1.37ms making 56 calls to Sorthash::as_string, avg 24µs/call
# spent 389µs making 56 calls to main::CORE:print, avg 7µs/call |
| 34 | |||||
| 35 | 56 | 57.1s | my $playcolour = $pickbest->( $moves, $adjcolbag, $board ); # spent 57.1s making 56 calls to main::incnply_pick_best, avg 1.02s/call | ||
| 36 | 56 | 258µs | print " playing $playcolour\n"; # spent 258µs making 56 calls to main::CORE:print, avg 5µs/call | ||
| 37 | 56 | 274ms | $board->changeregioncolour( $playcolour ); # spent 274ms making 56 calls to NewBoard::changeregioncolour, avg 4.88ms/call | ||
| 38 | 56 | 263ms | $board->extendregion; # spent 263ms making 56 calls to NewBoard::extendregion, avg 4.71ms/call | ||
| 39 | 56 | 348ms | $postmove->( $board, $playcolour ) if defined $postmove; # spent 348ms making 56 calls to main::incnply_makenm1ply, avg 6.22ms/call | ||
| 40 | } | ||||
| 41 | $moves--; | ||||
| 42 | 1 | 1µs | my( $nregion, $adjcolbag ) = $board->region; # spent 1µs making 1 call to NewBoard::region | ||
| 43 | 1 | 112µs | 2 | 1.01ms | print "\ngame over after $moves moves: board=\n$board\n"; # spent 906µs making 1 call to NewBoard::as_string
# spent 102µs making 1 call to main::CORE:print |
| 44 | 1 | 8µs | 2 | 10µs | print " adjcolbag = $adjcolbag, nregion=$nregion\n"; # spent 5µs making 1 call to Sorthash::as_string
# spent 5µs making 1 call to main::CORE:print |
| 45 | return $moves; | ||||
| 46 | } | ||||
| 47 | |||||
| 48 | |||||
| 49 | 1 | 2µs | 1; |