display duration time for each increment part
authordpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Sat, 20 Aug 2005 15:51:16 +0000 (15:51 +0000)
committerdpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Sat, 20 Aug 2005 15:51:16 +0000 (15:51 +0000)
git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@50 8392b6e1-25fa-0310-8288-cc32f8e212ea

bin/BackupPC_updatedb

index 155cbb1..f8a2865 100755 (executable)
@@ -198,6 +198,15 @@ INSERT INTO files
        VALUES (?,?,?,?,?,?,?,?)
 });
 
+sub fmt_time {
+       my $t = shift || return;
+       my $out = "";
+       my ($ss,$mm,$hh) = gmtime($t);
+       $out .= "${hh}h" if ($hh);
+       $out .= sprintf("%02d:%02d", $mm,$ss);
+       return $out;
+}
+
 foreach my $host_key (keys %{$hosts}) {
 
        my $hostname = $hosts->{$host_key}->{'host'} || die "can't find host for $host_key";
@@ -255,9 +264,11 @@ foreach my $host_key (keys %{$hosts}) {
                        $shareID = getShareID($share, $hostID, $hostname);
                
                        my ($f, $nf, $d, $nd) = recurseDir($bpc, $hostname, $files, $backupNum, $share, "", $shareID);
-                       printf(" %d/%d files %d/%d dirs [%.2f/s]\n",
+                       my $dur = (time() - $t) || 1;
+                       printf(" %d/%d files %d/%d dirs [%.2f/s dur: %s]\n",
                                $nf, $f, $nd, $d,
-                               ( ($f+$d) / ((time() - $t) || 1) )
+                               ( ($f+$d) / $dur ),
+                               fmt_time($dur)
                        );
                        $dbh->commit();
                }