Package org.anchoranalysis.core.time
Class ExecutionTimeRecorder
Object
ExecutionTimeRecorder
- Direct Known Subclasses:
ExecutionTimeRecorderIgnore
Records the execution-time of particular operations.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanisOperationAlreadyRecorded(String operationIdentifier) Has a particular operation already been recorded?abstract longmeasureTime(boolean start, String... operationIdentifiers) IndicatesoperationIdentifieris being recorded, and returns the current clock timestamp.abstract RecordedExecutionTimesThe execution-times that have been recorded.abstract voidrecordExecutionTime(String operationIdentifier, long millis) Records the execution-time of a particular operation.<E extends Exception>
voidrecordExecutionTime(String operationIdentifier, CheckedRunnable<E> operation) Executes anoperationwhile recording the execution-time - without a return type.<T,E extends Exception>
TrecordExecutionTime(String operationIdentifier, CheckedSupplier<T, E> operation) Executes anoperationwhile recording the execution-time - with a return type.voidrecordExecutionTimeUnchecked(String operationIdentifier, Runnable operation) Executes anoperationwhile recording the execution-time - without a return type, and without throwing an exception..voidrecordTimeDifferenceBetween(String operationIdentifier, long startTimestamp, long endTimestamp) Records the execution-time of a particular operation by subtracting the start-time from the end time.
-
Constructor Details
-
ExecutionTimeRecorder
public ExecutionTimeRecorder()
-
-
Method Details
-
recordedTimes
The execution-times that have been recorded.- Returns:
- newly created
RecordedExecutionTimesthat describes the execution-times.
-
recordExecutionTime
Records the execution-time of a particular operation.- Parameters:
operationIdentifier- a string uniquely identifying the operation.millis- how long the operation took in milliseconds.
-
isOperationAlreadyRecorded
Has a particular operation already been recorded?- Parameters:
operationIdentifier- a string uniquely identifying the operation.- Returns:
- true if the operation has already been recorded at least once, false otherwise.
-
recordExecutionTimeUnchecked
Executes anoperationwhile recording the execution-time - without a return type, and without throwing an exception..Operation times are always executed, even they throw an Exception or otherwise end in failure.
- Parameters:
operationIdentifier- an identifier for this type of write-operation, under which execution-times are aggregated.operation- the operation to execute
-
recordExecutionTime
public <E extends Exception> void recordExecutionTime(String operationIdentifier, CheckedRunnable<E> operation) throws E Executes anoperationwhile recording the execution-time - without a return type.Operation times are always executed, even they throw an Exception or otherwise end in failure.
- Type Parameters:
E- type of an exception thatoperationmay throw.- Parameters:
operationIdentifier- an identifier for this type of write-operation, under which execution-times are aggregated.operation- the operation to execute- Throws:
E- ifoperationthrows this exception;
-
recordExecutionTime
public <T,E extends Exception> T recordExecutionTime(String operationIdentifier, CheckedSupplier<T, E> operation) throws EExecutes anoperationwhile recording the execution-time - with a return type.Operation times are always executed, even they throw an Exception or otherwise end in failure.
- Type Parameters:
T- return-type ofoperation.E- type of an exception thatoperationmay throw.- Parameters:
operationIdentifier- an identifier for this type of write-operation, under which execution-times are aggregated.operation- the operation to execute- Returns:
- the value returned by
operation. - Throws:
E- ifoperationthrows this exception,
-
recordTimeDifferenceBetween
public void recordTimeDifferenceBetween(String operationIdentifier, long startTimestamp, long endTimestamp) Records the execution-time of a particular operation by subtracting the start-time from the end time.- Parameters:
operationIdentifier- a string uniquely identifying the operation.startTimestamp- a system clock timestamp (in milliseconds since the epoch) for when the operation began.endTimestamp- a system clock timestamp (in milliseconds since the epoch) for when the operation ended.
-
measureTime
IndicatesoperationIdentifieris being recorded, and returns the current clock timestamp.- Parameters:
start- true, if this time indicates the start of an operation. false, if it only describes the end.operationIdentifiers- all possible identifiers that may subsequently be used to record an end-time for this operation.- Returns:
- the a system clock timestamp (in milliseconds since the epoch).
-