public final class ProgressMeter
extends java.lang.Object
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.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_RECORD_LABEL
Default label for records in logger messages.
|
static 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)
|
static double |
DEFAULT_SECONDS_BETWEEN_UPDATES
By default, we output a line to the logger after this many seconds have elapsed
|
static java.util.function.LongSupplier |
DEFAULT_TIME_FUNCTION
By default, we use this function to get the current time
|
protected static org.apache.logging.log4j.Logger |
logger |
static long |
MILLISECONDS_PER_MINUTE
Number of milliseconds in a minute
|
static long |
MILLISECONDS_PER_SECOND
Number of milliseconds in a second
|
Constructor and Description |
---|
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(double secondsBetweenUpdates)
Create a progress meter with a custom update interval and the default time function
DEFAULT_TIME_FUNCTION |
Modifier and Type | Method and Description |
---|---|
void |
setRecordLabel(java.lang.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 time
|
void |
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 logger
|
boolean |
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.
|
protected static final org.apache.logging.log4j.Logger logger
public static final double DEFAULT_SECONDS_BETWEEN_UPDATES
public static final long DEFAULT_RECORDS_BETWEEN_TIME_CHECKS
public static final java.util.function.LongSupplier DEFAULT_TIME_FUNCTION
public static final long MILLISECONDS_PER_SECOND
public static final long MILLISECONDS_PER_MINUTE
public static final java.lang.String DEFAULT_RECORD_LABEL
public ProgressMeter()
DEFAULT_SECONDS_BETWEEN_UPDATES
seconds
and the default time function DEFAULT_TIME_FUNCTION
.public ProgressMeter(double secondsBetweenUpdates)
DEFAULT_TIME_FUNCTION
secondsBetweenUpdates
- number of seconds that should elapse before outputting a line to the loggerpublic void setRecordsBetweenTimeChecks(long recordsBetweenTimeChecks)
recordsBetweenTimeChecks
- number of records we need to process before we check the current timepublic void setRecordLabel(java.lang.String label)
DEFAULT_RECORD_LABEL
label
- Label to use for records in logger messages. Not null.public void start()
java.lang.IllegalStateException
- if the meter has been started before or has been stopped alreadypublic void update(htsjdk.samtools.util.Locatable currentLocus)
secondsBetweenUpdates
seconds.currentLocus
- the genomic location of the record just processed or null if the most recent record had no location.java.lang.IllegalStateException
- if the meter has not been started yet or has been stopped alreadypublic void update(htsjdk.samtools.util.Locatable currentLocus, long recordCountIncrease)
secondsBetweenUpdates
seconds.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.java.lang.IllegalStateException
- if the meter has not been started yet or has been stopped alreadypublic void stop()
java.lang.IllegalStateException
- if the meter has not been started yet or has been stopped alreadypublic boolean started()
start()
and true forever after.public boolean stopped()
stop()
and true forever after.