[Bio] / FigKernelPackages / Stats.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/Stats.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5, Tue Apr 29 05:49:26 2008 UTC revision 1.6, Fri Jul 11 01:02:28 2008 UTC
# Line 291  Line 291 
291      return @retVal;      return @retVal;
292  }  }
293    
294    =head3 Check
295    
296        my $flag = $stats->Check($counter => $period);
297    
298    Increment the specified statistic and return TRUE if the result is a
299    multiple of the specified period. This is a helpful method for generating
300    periodic trace messages. For example,
301    
302        Trace($stats->Ask('frogs') . " frogs processed.") if $stats->Check(frogs => 100) && T(3);
303    
304    will generate a trace message at level 3 for every 100 frogs processed.
305    
306    =over 4
307    
308    =item counter
309    
310    Name of the relevant statistic.
311    
312    =item period
313    
314    Periodicity value.
315    
316    =item RETURN
317    
318    Returns TRUE if the new value of the statistic is a multiple of the periodicity, else FALSE.
319    
320    =back
321    
322    =cut
323    
324    sub Check {
325        # Get the parameters.
326        my ($self, $counter, $period) = @_;
327        # Increment the statistic.
328        my $count = $self->Add($counter => 1);
329        # Check the new value against the periodicity.
330        my $retVal = ($count % $period == 0);
331        # Return the result.
332        return $retVal;
333    }
334    
335    =head3 Progress
336    
337        my $percent = $stats->Progress($counter => $total);
338    
339    Increment a statistic and return the percent progress toward a specified
340    total.
341    
342    =over 4
343    
344    =item counter
345    
346    Name of the relevant statistic.
347    
348    =item total
349    
350    Total number of objects being counted.
351    
352    =item RETURN
353    
354    Returns the percent of the total objects processed, including the current one.
355    
356    =back
357    
358    =cut
359    
360    sub Progress {
361        # Get the parameters.
362        my ($self, $counter, $total) = @_;
363        # Compute the return value.
364        my $retVal = $self->Add($counter => 1) * 100 / $total;
365        # Return the result.
366        return $retVal;
367    }
368    
369    
370  1;  1;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3