Class ProgressMeter

java.lang.Object
org.broadinstitute.hellbender.engine.ProgressMeter

public final class ProgressMeter extends Object
A basic progress meter to print out the number of records processed (and other metrics) during a traversal at a configurable time interval. Clients set the update interval at construction, which controls how many seconds must elapse before printing an update. Then call start() at traversal start, update(Locatable) after processing each record from the primary input, and stop() at traversal end to print summary statistics. Note that start() must only be called once, before any update(Locatable). Note no update(Locatable) must be called after stop(). All output is made at INFO level via log4j.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Default label for records in logger messages.
    static final long
    We check the current time every time we process this many records, by default (to cut down on the number of system calls)
    static final double
    By default, we output a line to the logger after this many seconds have elapsed
    static final LongSupplier
    By default, we use this function to get the current time
    protected static final org.apache.logging.log4j.Logger
     
    static final long
    Number of milliseconds in a minute
    static final long
    Number of milliseconds in a second
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a progress meter with the default update interval of DEFAULT_SECONDS_BETWEEN_UPDATES seconds and the default time function DEFAULT_TIME_FUNCTION.
    ProgressMeter(double secondsBetweenUpdates)
    Create a progress meter with a custom update interval and the default time function DEFAULT_TIME_FUNCTION
    ProgressMeter(double secondsBetweenUpdates, boolean disabled)
    Create a progress meter with a custom update interval and the default time function DEFAULT_TIME_FUNCTION, and allows the ProgressMeter to be set as disabled
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Change the label used for records in logger messages.
    void
    setRecordsBetweenTimeChecks(long recordsBetweenTimeChecks)
    Set the number of records we need to process before we check the current time
    void
    Start the progress meter and produce preliminary output such as column headings.
    boolean
    Returns whether the meter has been started.
    void
    Stop the progress meter and output summary statistics to the logger
    boolean
    Returns whether the meter has been stopped.
    void
    update(htsjdk.samtools.util.Locatable currentLocus)
    Signal to the progress meter that an additional record has been processed.
    void
    update(htsjdk.samtools.util.Locatable currentLocus, long recordCountIncrease)
    Signal to the progress meter that several additional records hav been processed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • logger

      protected static final org.apache.logging.log4j.Logger logger
    • DEFAULT_SECONDS_BETWEEN_UPDATES

      public static final double DEFAULT_SECONDS_BETWEEN_UPDATES
      By default, we output a line to the logger after this many seconds have elapsed
      See Also:
    • DEFAULT_RECORDS_BETWEEN_TIME_CHECKS

      public static final long DEFAULT_RECORDS_BETWEEN_TIME_CHECKS
      We check the current time every time we process this many records, by default (to cut down on the number of system calls)
      See Also:
    • DEFAULT_TIME_FUNCTION

      public static final LongSupplier DEFAULT_TIME_FUNCTION
      By default, we use this function to get the current time
    • MILLISECONDS_PER_SECOND

      public static final long MILLISECONDS_PER_SECOND
      Number of milliseconds in a second
      See Also:
    • MILLISECONDS_PER_MINUTE

      public static final long MILLISECONDS_PER_MINUTE
      Number of milliseconds in a minute
      See Also:
    • DEFAULT_RECORD_LABEL

      public static final String DEFAULT_RECORD_LABEL
      Default label for records in logger messages. For display purposes only.
      See Also:
  • Constructor Details

    • ProgressMeter

      public ProgressMeter()
      Create a progress meter with the default update interval of DEFAULT_SECONDS_BETWEEN_UPDATES seconds and the default time function DEFAULT_TIME_FUNCTION.
    • ProgressMeter

      public ProgressMeter(double secondsBetweenUpdates)
      Create a progress meter with a custom update interval and the default time function DEFAULT_TIME_FUNCTION
      Parameters:
      secondsBetweenUpdates - number of seconds that should elapse before outputting a line to the logger
    • ProgressMeter

      public ProgressMeter(double secondsBetweenUpdates, boolean disabled)
      Create a progress meter with a custom update interval and the default time function DEFAULT_TIME_FUNCTION, and allows the ProgressMeter to be set as disabled
      Parameters:
      secondsBetweenUpdates - number of seconds that should elapse before outputting a line to the logger
      disabled - if true, set this ProgressMeter to be disabled, so that all operations on it are no-ops
  • Method Details

    • setRecordsBetweenTimeChecks

      public void setRecordsBetweenTimeChecks(long recordsBetweenTimeChecks)
      Set the number of records we need to process before we check the current time
      Parameters:
      recordsBetweenTimeChecks - number of records we need to process before we check the current time
    • setRecordLabel

      public void setRecordLabel(String label)
      Change the label used for records in logger messages. Default label is DEFAULT_RECORD_LABEL
      Parameters:
      label - Label to use for records in logger messages. Not null.
    • start

      public void start()
      Start the progress meter and produce preliminary output such as column headings.
      Throws:
      IllegalStateException - if the meter has been started before or has been stopped already
    • update

      public void update(htsjdk.samtools.util.Locatable currentLocus)
      Signal to the progress meter that an additional record has been processed. Will output statistics to the logger roughly every secondsBetweenUpdates seconds.
      Parameters:
      currentLocus - the genomic location of the record just processed or null if the most recent record had no location.
      Throws:
      IllegalStateException - if the meter has not been started yet or has been stopped already
    • update

      public void update(htsjdk.samtools.util.Locatable currentLocus, long recordCountIncrease)
      Signal to the progress meter that several additional records hav been processed. Will output statistics to the logger roughly every secondsBetweenUpdates seconds.
      Parameters:
      currentLocus - the genomic location of the last record just processed or null if the most recent record had no location.
      recordCountIncrease - number of new records processed.
      Throws:
      IllegalStateException - if the meter has not been started yet or has been stopped already
    • stop

      public void stop()
      Stop the progress meter and output summary statistics to the logger
      Throws:
      IllegalStateException - if the meter has not been started yet or has been stopped already
    • started

      public boolean started()
      Returns whether the meter has been started. It returns false before the call to start() and true forever after.
    • stopped

      public boolean stopped()
      Returns whether the meter has been stopped. It returns false before the call to stop() and true forever after.