--- genlop 2009-10-19 09:50:12.000000000 -0400 +++ genlop.fast 2009-10-19 09:49:59.000000000 -0400 @@ -567,36 +567,72 @@ print; } } - my $last_ebuild; - foreach my $ebuild_arg (@targets) - { + my $last_ebuild; - # we track the last ebuild processed with $last_ebuild variable - $last_ebuild = $ebuild_arg; - $ebuild_arg =~ s/(\+)/\\$1/g; - foreach my $logfile (@logfiles) + my %pkg_times; + my %local_pkg_times; + foreach my $logfile (@logfiles) + { + my $handle; + my $pkg_name; + open_file($logfile, \$handle); + foreach (<$handle>) { - my $handle; - open_file($logfile, \$handle); - foreach (<$handle>) + if (m/^(\d+):\s+>>>\s+emerge \(\d+ of \d+\) ([^ ]+) to/) { - if (m/^(.*?)\: \>\>\> emerge.*?\/$ebuild_arg-[0-9].*/) - { - $e_start = $1; - } - if (m/^(.*?)\: ::: completed .*?\) .*\/$ebuild_arg-[0-9].* to \//) - { - $e_end = $1; - $tm_secondi += ($e_end - $e_start); - $e_count++; + my $e_start = $1; + my $pkg_name = $2; + $local_pkg_times{$pkg_name}{e_start} = $e_start; + #print $_; print "e_start = [$e_start] pkg_name = [$pkg_name]\n"; + } + if (m/^(\d+):\s+:::\s+completed emerge \(\d+ of \d+\) ([^ ]+) to/) + { + my $e_end = $1; + my $pkg_name = $2; + if($local_pkg_times{$pkg_name}{e_start} > 0) { + #TODO: also consider stripping the version number out + # to allow merging stats across versions... + $e_start = $local_pkg_times{$pkg_name}{e_start}; + $pkg_times{$pkg_name}{e_count}++; + $pkg_times{$pkg_name}{tm_secondi} += ($e_end - $e_start); + + $pkg_name=~m|^.*/(.*?)-\d|; + my $tgt = $1; + $pkg_times{$tgt}{e_count}++; + $pkg_times{$tgt}{tm_secondi} += ($e_end - $e_start); + #print "e_end = [$e_end] e_count[$pkg_times{$pkg_name}{e_count}] pkg_name = [$pkg_name]\n"; } } } + } + foreach my $pkg_name (keys(%pkg_times)) { + my $ec = $pkg_times{$pkg_name}{e_count}; + my $tm = $pkg_times{$pkg_name}{tm_secondi}; + #if($ec == 0) { print "Strange package: $pkg_name\n"; next; } + $pkg_times{$pkg_name}{m_secondi} = ($tm / $ec); + } + + + foreach my $ebuild_arg (@targets) + { + # we track the last ebuild processed with $last_ebuild variable + $last_ebuild = $ebuild_arg; + $ebuild_arg =~ s/(\+)/\\$1/g; + + if(defined($pkg_times{$last_ebuild})){ + $e_count = $pkg_times{$last_ebuild}{e_count}; + $tm_secondi = $pkg_times{$last_ebuild}{tm_secondi}; + gtime( ($tm_secondi / $e_count)); + my $hstr = (($days * 24) + $hours > 0)?(sprintf("%2dh", ($days * 24) + $hours)):(sprintf("%2s ", "")); + my $mstr = ($mins > 0)?(sprintf("%2dm", $mins)):(sprintf("%2s ", ""));; + my $sstr = ($secs > 0)?(sprintf("%2ds", $secs)):(sprintf("%2s ", ""));; + printf("%30s [%3s %3s %3s]\n", $last_ebuild, $hstr, $mstr, $sstr); + } + if ($e_count == 0) { if ($online_query) { - #query gentoo.linuxhowtos.org $tm_secondi += lhtoquery($last_ebuild, \$e_count); }