Lines 567-602
Link Here
|
567 |
print; |
567 |
print; |
568 |
} |
568 |
} |
569 |
} |
569 |
} |
570 |
my $last_ebuild; |
570 |
my $last_ebuild; |
571 |
foreach my $ebuild_arg (@targets) |
|
|
572 |
{ |
573 |
|
571 |
|
574 |
# we track the last ebuild processed with $last_ebuild variable |
572 |
my %pkg_times; |
575 |
$last_ebuild = $ebuild_arg; |
573 |
my %local_pkg_times; |
576 |
$ebuild_arg =~ s/(\+)/\\$1/g; |
574 |
foreach my $logfile (@logfiles) |
577 |
foreach my $logfile (@logfiles) |
575 |
{ |
|
|
576 |
my $handle; |
577 |
my $pkg_name; |
578 |
open_file($logfile, \$handle); |
579 |
foreach (<$handle>) |
578 |
{ |
580 |
{ |
579 |
my $handle; |
581 |
if (m/^(\d+):\s+>>>\s+emerge \(\d+ of \d+\) ([^ ]+) to/) |
580 |
open_file($logfile, \$handle); |
|
|
581 |
foreach (<$handle>) |
582 |
{ |
582 |
{ |
583 |
if (m/^(.*?)\: \>\>\> emerge.*?\/$ebuild_arg-[0-9].*/) |
583 |
my $e_start = $1; |
584 |
{ |
584 |
my $pkg_name = $2; |
585 |
$e_start = $1; |
585 |
$local_pkg_times{$pkg_name}{e_start} = $e_start; |
586 |
} |
586 |
#print $_; print "e_start = [$e_start] pkg_name = [$pkg_name]\n"; |
587 |
if (m/^(.*?)\: ::: completed .*?\) .*\/$ebuild_arg-[0-9].* to \//) |
587 |
} |
588 |
{ |
588 |
if (m/^(\d+):\s+:::\s+completed emerge \(\d+ of \d+\) ([^ ]+) to/) |
589 |
$e_end = $1; |
589 |
{ |
590 |
$tm_secondi += ($e_end - $e_start); |
590 |
my $e_end = $1; |
591 |
$e_count++; |
591 |
my $pkg_name = $2; |
|
|
592 |
if($local_pkg_times{$pkg_name}{e_start} > 0) { |
593 |
#TODO: also consider stripping the version number out |
594 |
# to allow merging stats across versions... |
595 |
$e_start = $local_pkg_times{$pkg_name}{e_start}; |
596 |
$pkg_times{$pkg_name}{e_count}++; |
597 |
$pkg_times{$pkg_name}{tm_secondi} += ($e_end - $e_start); |
598 |
|
599 |
$pkg_name=~m|^.*/(.*?)-\d|; |
600 |
my $tgt = $1; |
601 |
$pkg_times{$tgt}{e_count}++; |
602 |
$pkg_times{$tgt}{tm_secondi} += ($e_end - $e_start); |
603 |
#print "e_end = [$e_end] e_count[$pkg_times{$pkg_name}{e_count}] pkg_name = [$pkg_name]\n"; |
592 |
} |
604 |
} |
593 |
} |
605 |
} |
594 |
} |
606 |
} |
|
|
607 |
} |
608 |
foreach my $pkg_name (keys(%pkg_times)) { |
609 |
my $ec = $pkg_times{$pkg_name}{e_count}; |
610 |
my $tm = $pkg_times{$pkg_name}{tm_secondi}; |
611 |
#if($ec == 0) { print "Strange package: $pkg_name\n"; next; } |
612 |
$pkg_times{$pkg_name}{m_secondi} = ($tm / $ec); |
613 |
} |
614 |
|
615 |
|
616 |
foreach my $ebuild_arg (@targets) |
617 |
{ |
618 |
# we track the last ebuild processed with $last_ebuild variable |
619 |
$last_ebuild = $ebuild_arg; |
620 |
$ebuild_arg =~ s/(\+)/\\$1/g; |
621 |
|
622 |
if(defined($pkg_times{$last_ebuild})){ |
623 |
$e_count = $pkg_times{$last_ebuild}{e_count}; |
624 |
$tm_secondi = $pkg_times{$last_ebuild}{tm_secondi}; |
625 |
gtime( ($tm_secondi / $e_count)); |
626 |
my $hstr = (($days * 24) + $hours > 0)?(sprintf("%2dh", ($days * 24) + $hours)):(sprintf("%2s ", "")); |
627 |
my $mstr = ($mins > 0)?(sprintf("%2dm", $mins)):(sprintf("%2s ", ""));; |
628 |
my $sstr = ($secs > 0)?(sprintf("%2ds", $secs)):(sprintf("%2s ", ""));; |
629 |
printf("%30s [%3s %3s %3s]\n", $last_ebuild, $hstr, $mstr, $sstr); |
630 |
} |
631 |
|
595 |
if ($e_count == 0) |
632 |
if ($e_count == 0) |
596 |
{ |
633 |
{ |
597 |
if ($online_query) |
634 |
if ($online_query) |
598 |
{ |
635 |
{ |
599 |
|
|
|
600 |
#query gentoo.linuxhowtos.org |
636 |
#query gentoo.linuxhowtos.org |
601 |
$tm_secondi += lhtoquery($last_ebuild, \$e_count); |
637 |
$tm_secondi += lhtoquery($last_ebuild, \$e_count); |
602 |
} |
638 |
} |