Class ProgressMeter
java.lang.Object
org.broadinstitute.hellbender.engine.ProgressMeter
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
FieldsModifier and TypeFieldDescriptionstatic 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 elapsedstatic final LongSupplier
By default, we use this function to get the current timeprotected static final org.apache.logging.log4j.Logger
static final long
Number of milliseconds in a minutestatic final long
Number of milliseconds in a second -
Constructor Summary
ConstructorsConstructorDescriptionCreate a progress meter with the default update interval ofDEFAULT_SECONDS_BETWEEN_UPDATES
seconds and the default time functionDEFAULT_TIME_FUNCTION
.ProgressMeter
(double secondsBetweenUpdates) Create a progress meter with a custom update interval and the default time functionDEFAULT_TIME_FUNCTION
ProgressMeter
(double secondsBetweenUpdates, boolean disabled) Create a progress meter with a custom update interval and the default time functionDEFAULT_TIME_FUNCTION
, and allows the ProgressMeter to be set as disabled -
Method Summary
Modifier and TypeMethodDescriptionvoid
setRecordLabel
(String label) 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 timevoid
start()
Start the progress meter and produce preliminary output such as column headings.boolean
started()
Returns whether the meter has been started.void
stop()
Stop the progress meter and output summary statistics to the loggerboolean
stopped()
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.
-
Field Details
-
logger
protected static final org.apache.logging.log4j.Logger logger -
DEFAULT_SECONDS_BETWEEN_UPDATES
public static final double DEFAULT_SECONDS_BETWEEN_UPDATESBy 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_CHECKSWe 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
By default, we use this function to get the current time -
MILLISECONDS_PER_SECOND
public static final long MILLISECONDS_PER_SECONDNumber of milliseconds in a second- See Also:
-
MILLISECONDS_PER_MINUTE
public static final long MILLISECONDS_PER_MINUTENumber of milliseconds in a minute- See Also:
-
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 ofDEFAULT_SECONDS_BETWEEN_UPDATES
seconds and the default time functionDEFAULT_TIME_FUNCTION
. -
ProgressMeter
public ProgressMeter(double secondsBetweenUpdates) Create a progress meter with a custom update interval and the default time functionDEFAULT_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 functionDEFAULT_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 loggerdisabled
- 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
Change the label used for records in logger messages. Default label isDEFAULT_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 everysecondsBetweenUpdates
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 everysecondsBetweenUpdates
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 tostart()
and true forever after. -
stopped
public boolean stopped()Returns whether the meter has been stopped. It returns false before the call tostop()
and true forever after.
-