[Home] [By Thread] [By Date] [Recent Entries]
Andrew Welch schrieb:
I often do:
mludwig@forelle:~/Werkstatt/xsl > cat timer.pl use strict; use warnings; use Time::HiRes 'time'; my $t0 = time; while (<>) { chomp; my($processed, $total) = m#(\d+)/(\d+)#g; if (! ($processed and $total) or $processed > $total) { warn "problem understanding '$_'\n"; next; } my $percent = 100.0 * $processed / $total; my $time_used = time - $t0; my $time_per_item = $time_used / $processed || 1; if ($processed == $total) { printf "Processed %u/%u in %.2f s, %.5f s per item\n", $processed, $total, $time_used, $time_per_item; last; } my $timeleft = $time_per_item * ($total - $processed); printf "Processed %u/%u in %.2f s, %.2f%%, %.2f s estimated till end\n", $processed, $total, $time_used, $percent, $timeleft; } mludwig@forelle:~/Werkstatt/xsl > for t in $(seq 1 10); do sleep 0.3; echo $t/10; done | perl timer.pl Processed 1/10 in 0.29 s, 10.00%, 2.59 s estimated till end Processed 2/10 in 0.60 s, 20.00%, 2.38 s estimated till end Processed 3/10 in 0.90 s, 30.00%, 2.11 s estimated till end Processed 4/10 in 1.21 s, 40.00%, 1.82 s estimated till end Processed 5/10 in 1.52 s, 50.00%, 1.52 s estimated till end Processed 6/10 in 1.83 s, 60.00%, 1.22 s estimated till end Processed 7/10 in 2.14 s, 70.00%, 0.92 s estimated till end Processed 8/10 in 2.44 s, 80.00%, 0.61 s estimated till end Processed 9/10 in 2.76 s, 90.00%, 0.31 s estimated till end Processed 10/10 in 3.06 s, 0.30617 s per item Michael
|

Cart



