User Tools

Site Tools


perl:loop_with_timekeeping
my $timeStart = time;
 
my $itDone=0;
my $itTotal; # Set to the total number of iterations
 
# LOOP BEGIN {
 
	# LOOP BODY;
 
	$itDone++;
 
	my $timeProc = (time() - $timeStart)||1;
	my $speed = ($itDone/$timeProc) || -1; # files/second
	my $etaS = int($itTotal - $itDone)/$speed; #seconds
	my $etaM = int($etaS/60); $etaS %= 60;
	my $etaH = int($etaM/60); $etaM %= 60; 
	printf "  >> $itDone/$itTotal = %.1f%%, $timeProc s, %0.2f it/s, ETA %d:%02d:%02d\n",($itDone/$itTotal*100),$speed,$etaH,$etaM,$etaS;
#} LOOP END
perl/loop_with_timekeeping.txt · Last modified: 2009/08/13 09:56 by tkbletsc

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki