Top Description Inners Fields Constructors Methods
org.freedesktop.dbus.utils

public Class TimeMeasure

extends Object
Class Inheritance
Imports
java.text.DateFormat, .SimpleDateFormat, java.time.Duration, java.util.Date, .TimeZone

Utility class for time measurements. Instances may be reset for reuse.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface

Field Summary

Modifier and TypeField and Description
private volatile long
startTm

Start time in nanoseconds.

private final TimeMeasure.ITimeMeasureFormat
tmf

Formatter used for toString()

Constructor Summary

AccessConstructor and Description
public
TimeMeasure(TimeMeasure.ITimeMeasureFormat
formatter to use for toString() call
_formatter
)

Create a new instance using _ts millis as

public
TimeMeasure()

Create a new instance, used a formatter converting everything >= 5000 ms to seconds (X.Y -> 6.1).

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

elapsed time in ms
getElapsed
()

Returns the elapsed time in milliseconds.

public long
public String

Returns:

formatted string
getElapsedFormatted
(DateFormat
date format
_dateFormat
)

Formats the elapsed time using the given dateFormatter.

pack-priv String

Returns:

formatted string
getElapsedFormatted
(DateFormat _dateFormat, long _elapsedTime)

Same as above, used for proper unit testing.

public long

Returns:

elapsed time in seconds
getElapsedSeconds
()

Returns the elapsed time in seconds.

public long

Returns:

start time in ms
getStartTime
()

Returns the start time in milliseconds.

public final TimeMeasure

Returns:

the object
reset
()

Resets the start time.

pack-priv void
setStartTm(long _tm)

Change the start time (for unit testing only!).

public String

Returns:

elapsed time in ms
toString
()

Overrides java.lang.Object.toString.

Returns the elapsed time in milliseconds formatted as string.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

startTmback to summary
private volatile long startTm

Start time in nanoseconds.

tmfback to summary
private final TimeMeasure.ITimeMeasureFormat tmf

Formatter used for toString()

Constructor Detail

TimeMeasureback to summary
public TimeMeasure(TimeMeasure.ITimeMeasureFormat _formatter)

Create a new instance using _ts millis as

Parameters
_formatter:TimeMeasure.ITimeMeasureFormat

formatter to use for toString() call

TimeMeasureback to summary
public TimeMeasure()

Create a new instance, used a formatter converting everything >= 5000 ms to seconds (X.Y -> 6.1).

Method Detail

getElapsedback to summary
public long getElapsed()

Returns the elapsed time in milliseconds.

Returns:long

elapsed time in ms

getElapsedAndResetback to summary
public long getElapsedAndReset()
getElapsedFormattedback to summary
public String getElapsedFormatted(DateFormat _dateFormat)

Formats the elapsed time using the given dateFormatter. If null is given, a new Formatter with format HH:mm:ss.SSS will be used. The timezone of the given dateFormatter will always be set to 'UTC' to avoid any timezone related offsets.

Parameters
_dateFormat:DateFormat

date format

Returns:String

formatted string

getElapsedFormattedback to summary
pack-priv String getElapsedFormatted(DateFormat _dateFormat, long _elapsedTime)

Same as above, used for proper unit testing.

Returns:String

formatted string

getElapsedSecondsback to summary
public long getElapsedSeconds()

Returns the elapsed time in seconds.

Returns:long

elapsed time in seconds

getStartTimeback to summary
public long getStartTime()

Returns the start time in milliseconds.

Returns:long

start time in ms

resetback to summary
public final TimeMeasure reset()

Resets the start time.

Returns:TimeMeasure

the object

setStartTmback to summary
pack-priv void setStartTm(long _tm)

Change the start time (for unit testing only!).

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns the elapsed time in milliseconds formatted as string.

Returns:String

elapsed time in ms

Annotations
@Override
org.freedesktop.dbus.utils back to summary

public Interface TimeMeasure.ITimeMeasureFormat


Method Summary

Modifier and TypeMethod and Description
public String
format(long _durationInMillis)

Method Detail

formatback to summary
public String format(long _durationInMillis)