Class TestClock
java.lang.Object
io.opencensus.common.Clock
io.opencensus.testing.common.TestClock
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadvanceTime(Duration duration) Advances the time by a duration.static TestClockcreate()Creates a clock initialized to a constant non-zero time.static TestClockCreates a clock with the given time.private static longnow()Obtains the current instant from this clock.longnowNanos()Returns a time measurement with nanosecond precision that can only be used to calculate elapsed time.voidSets the time.private static TimestampvalidateNanos(Timestamp time)
-
Field Details
-
NUM_NANOS_PER_SECOND
private static final int NUM_NANOS_PER_SECOND- See Also:
-
currentTime
-
-
Constructor Details
-
TestClock
private TestClock()
-
-
Method Details
-
create
Creates a clock initialized to a constant non-zero time.Timestamp.create(0, 0)is not a good default, because it represents an invalid time.- Returns:
- a clock initialized to a constant non-zero time.
- Since:
- 0.5
-
create
-
setTime
-
advanceTime
Advances the time by a duration.- Parameters:
duration- the increase in time.- Since:
- 0.5
-
now
-
nowNanos
public long nowNanos()Description copied from class:ClockReturns a time measurement with nanosecond precision that can only be used to calculate elapsed time. -
validateNanos
-
getNanos
-