2 # parse 'yosys -t' logfile and find slow passes
5 my %last_line_by_depth;
6 my %last_time_by_depth;
15 next unless /^\[([0-9.]+)\] (([0-9]+\.)+)/;
16 my ($this_time, $this_id, $this_header) = ($1, $2, $4);
24 $depth = length $depth;
25 $max_depth = $depth if $depth > $max_depth;
27 for (my $i = $depth; $i <= $max_depth; $i++) {
28 next unless exists $last_time_by_depth{$i};
29 $lines_time[$last_line_by_depth{$i}] = $this_time-$last_time_by_depth{$i};
30 delete $last_time_by_depth{$i};
31 delete $last_header_by_depth{$i};
34 $last_time_by_depth{$depth} = $this_time;
35 $last_line_by_depth{$depth} = $#lines_text;
36 $lines_depth[$#lines_text] = $depth;
39 for (my $depth = 1; $depth <= $max_depth; $depth++) {
40 printf "\nSlow passes on recursion depth %d:\n", $depth;
42 for (my $i = 0; $i <= $#lines_text; $i++) {
43 next if $lines_depth[$i] != $depth or $lines_time[$i] < 1.0;
44 push @lines, sprintf("%3d %08.2f %s\n", $lines_depth[$i], $lines_time[$i], $lines_text[$i]);
46 for my $line (sort {$b cmp $a} @lines) {
51 printf "\nFull journal of headers:\n";
52 for (my $i = 0; $i <= $#lines_text; $i++) {
53 printf "%3d %08.2f %s\n", $lines_depth[$i], $lines_time[$i], $lines_text[$i];