fixed time estimation
authorHeiko Schlittermann (DTELE) <hs@schlittermann.de>
Mon, 15 Aug 2011 15:50:38 +0200
changeset 54 2d3d0e2e81e7
parent 53 4407a98ca072
child 58 f837948e43a4
fixed time estimation
bin/imager.check
--- a/bin/imager.check	Mon Aug 15 15:34:44 2011 +0200
+++ b/bin/imager.check	Mon Aug 15 15:50:38 2011 +0200
@@ -95,7 +95,7 @@
 sub purge_unused {
     my ($dir, %block) = @_;
 
-    my ($total, $done);
+    my ($total, $done, $t0);
     verbose("# pass 1 - checking for unused blocks");
     verbose("#          estimating file count");
 
@@ -113,12 +113,13 @@
     verbose("#          got $total blocks/files");
 
     # progress
+    $t0 = time;
     local $SIG{ALRM} = sub {
         return alarm 1 if not $done;
-        my $speed = $done / (time - $^T + 1);
+        my $speed = $done / (time - $t0 + 1);
         verbose sprintf "# pass 1 done %5.1f%% | %25s (%*d of %d blocks)",
           100 * ($done / $total),
-          scalar(localtime($^T + $speed * ($total - $done))),
+          scalar(localtime $t0 + $total/$speed),
           length($total) => $done,
           $total;
         alarm 5;
@@ -183,16 +184,17 @@
 
     my $total = grep { $_ ne "" } keys(%block);
     my $done = 0;
+    my $t0 = time;
 
     verbose("# pass 2 - checking image completeness");
 
     # progress
     local $SIG{ALRM} = sub {
         return alarm 1 if not $done;
-        my $speed = $done / (time - $^T + 1);
+        my $speed = $done / (time - $t0 + 1);
         verbose sprintf "# pass 2 done %5.1f%% | %25s (%*d of %d blocks)",
           100 * $done / $total,
-          scalar(localtime($^T + ($total - $done) * $speed)),
+          scalar(localtime $t0 + $total/$speed),
           length($total) => $done,
           $total;
         alarm 5;