my $current = shift;
my $total = shift || 1;
my $p = int($current * 100 / $total);
- if ($p < $last_p) {
+ if ($p < $last_p || $current == 1) {
$start_t = time();
+ $last_p = 0;
} elsif ($p != $last_p) {
my $rate = ($current / (time() - $start_t || 1));
my $eta = ($total-$current) / ($rate || 1);
}
my $fake_dir = 1;
+ my $fake_pos = 0;
+ my $last_fake_t = time();
sub fakeprogress {
return if (! $show_progress);
my $current = shift @_;
- my @ind = ('-','\\','|','/','-','\\','|','/', '-');
+ my @ind = ('-','\\','|','/','-','\\','|','/');
- $last_p += $fake_dir;
- $fake_dir = -$fake_dir if ($last_p > 1000 || $last_p < 0);
- if ($last_p % 10 == 0) {
- printf STDERR ("%5d / %5s [%-51s]\r",$current,"?"," " x ($last_p/20).$ind[($last_p/20) % $#ind]);
+ if ($current < $fake_pos) {
+ $start_t = time();
+ $last_fake_t = 0;
+ $fake_dir = 1;
+ $fake_pos = 0;
+ }
+
+ if (time()-$last_fake_t >= 1) {
+ $last_fake_t = time();
+ $fake_pos += $fake_dir;
+ $fake_dir = -$fake_dir if ($fake_pos > 38);
+ }
+
+ if ($current % 10 == 0) {
+ my $rate = ($current / (time() - $start_t || 1));
+ printf STDERR ("%5d [%-38s] %0.1f/s\r",$current, " " x $fake_pos .$ind[($current / 10) % 8], $rate);
}
}