Subject: | Wishes: default report format, Time::Progress::File |
Some suggestions for your nice module:
- It would be nice for lazy developers to have a default report format.
- It would be nice if the frequency of report updates could be
specified. I think it's more performant to check for the current time,
the time of the last report, and output the report only once a second or so.
Currently I am doing it like this:
my $tp = Time::Progress->new(...);
my $last_report = time-1;
while(...) {
if ($last_report+1 < time) {
print STDERR $tp->report(undef, $c);
$last_report = time;
}
}
It would be nicer if this could be done by Time::Progress, e.g.
my $tp = Time::Progress->new(..., report_update => 2);
while(...) {
$tp->print_report(\*STDERR, undef, $c); # would only output the
report every two seconds
}
- I think a common operation is showing progress while iterating over a
file. Currently I do this using
$tp = Time::Progress->new(min => 0, max => -s $filename, format => ...);
open my $fh, $filename or die;
while(<$fh>) {
$tp->report(undef, tell($fh));
}
It would be nice if this could be written like this:
open my $fh, $filename or die;
$tp = Time::Progress::File->new(fh => $fh);
while(<$fh>) {
$tp->report; # would use the default format and tell($fh)
}
If you don't think that the latter fits into your distribution, then
I would create it myself.
Regards,
Slaven