This class provides an interface into system dependent timer values (usually 64 bit tick counters) that we call ticks. Ticks and this class allow to store and calculate time values in an efficient and highly accurate way.
Ticks generated by this class can be added and subtracted:
Conversion functions to milliseconds, microseconds and nanoseconds accept ticks and span values in ticks in the same manner.
As Ticks are system dependent, they should not be stored in system independent data files or otherwise shared between systems. In general such values should only be used by methods of this class and class TickWatch.
The resolution and accuracy of the values is platform dependent. Especially nanoseconds are deemed to be not accurate and above 100 ns (this was written and fact in 2013).
Public Static Fields | |
static readonly Ticks | CreationTime |
static readonly long | InternalFrequency |
Public Methods | |
Ticks () | |
Ticks (long ticks) | |
Ticks (Ticks copy) | |
void | Add (long value) |
void | Add (Ticks other) |
Ticks | Age () |
Ticks | Age (Ticks result) |
void | FromDays (long days) |
void | FromHours (long hours) |
void | FromMicros (long micros) |
void | FromMillis (long millis) |
void | FromMinutes (long mins) |
void | FromNanos (long nanos) |
void | FromSeconds (long secs) |
bool | HasElapsed (Ticks waitTime) |
long | InDays () |
DateTime | InDotNetDateTime () |
long | InDotNetDateTimeTicks () |
long | InEpochMillis () |
double | InHertz (int qtyFractionalDigits=-1) |
long | InHours () |
long | InMicros () |
long | InMillis () |
long | InMinutes () |
long | InNanos () |
long | InSeconds () |
long | Raw () |
void | Set () |
void | Set (Ticks other) |
void | SetFromDotNetDateTime (DateTime dateTime) |
void | SetFromEpochMillis (long epochMillis) |
void | SetRaw (long value) |
Ticks | Since (Ticks olderTime) |
Ticks | Since (Ticks olderTime, Ticks result) |
void | Sub (long value) |
void | Sub (Ticks other) |
string | ToString (string formatString, System.IFormatProvider fProvider) |
Private Static Fields | |
static readonly double | convSWToDT |
A conversion factor between stopwatch ticks and DateTimeTicks. */. | |
static readonly Stopwatch | creationTimeStopWatch |
A stopwatch started when static constructor is invoked. */. | |
static readonly long | dateTimeTicks19700101 |
The DateTime.Now.Ticks at 1/1/1970 0:00:00. */. | |
Protected Fields | |
Ticks | tempTicks |
A temporary ticks object. used for as a return value. */. | |
long | ticks |
The value. */. | |
|
inline |
Creates a Ticks instance representing the point in time when this constructor was invoked.
Creates a Ticks instance representing the same point in time or time span as the instance provided.
copy | The instance to copy the ticks value from. |
|
inline |
Creates a Ticks instance representing a given time point or time span in ticks.
ticks | The value to copy into this. |
|
inline |
Adds the point in time or time span represented by the given Ticks instance to this instance.
value | The ticks to add. |
|
inline |
|
inline |
Returns the time span between value represented by this instance and the current system time. If the internal value represents a historic point in time, the result is positive.
Note: Attention: The object returned is a temporary object, deemed to be reused by other interface methods of this instance. Therefore, it must be used only until subsequent method invocations on this instance are performed (hence, also not thread safe!) Use Age(Ticks result) to provide a dedicated external result instance.
Returns the time span between value represented by this instance and the current time. If the internal value represents a historic point in time, the result is positive.
result | The Ticks object to store the result in. If null, this is created. |
|
inline |
Sets the internal value to a time span provided in days.
days | The time span to set in days. |
|
inline |
Sets the internal value to a time span provided in hours.
hours | The time span to set in hours. |
|
inline |
Sets the internal value to a time span provided in microseconds.
micros | The time span to set in microseconds. |
|
inline |
Sets the internal value to a time span provided in milliseconds.
millis | The time span to set in milliseconds. |
|
inline |
Sets the internal value to a time span provided in minutes.
mins | The time span to set in minutes. |
|
inline |
Sets the internal value to a time span provided in nanoseconds.
nanos | The time span to set in nanoseconds. |
|
inline |
Sets the internal value to a time span provided in seconds.
secs | The time span to set in seconds. |
|
inline |
Determines if this objects' age is higher than a given time span.
waitTime | A Ticks object representing a time span. |
true
if the given Ticks object representing a time span is smaller or equal than our age. false
otherwise.
|
inline |
Converts the internal value to days.
|
inline |
Converts the internal value to DateTime. The conversion is dependent on time zone and system clock setting of the host.
|
inline |
Converts the internal value to DateTime ticks. The conversion is dependent on time zone and system clock setting of the host.
|
inline |
Converts the internal value into milliseconds since January 1, 1970, 00:00:00 GMT. The conversion is dependent on time zone and system clock setting of the host.
|
inline |
Returns 1 divided by internal value in seconds, hence the number of Hertz that this Ticks object represents when interpreted as a time span.
qtyFractionalDigits | Number of digits that the return value will be rounded to. Defaults to -1 which means no rounding. |
|
inline |
Converts the internal value to hours.
|
inline |
Converts the internal value to microseconds.
|
inline |
Converts the internal value to milliseconds.
|
inline |
Converts the internal value to minutes.
|
inline |
Converts the internal value to nanoseconds.
|
inline |
Converts the internal value to seconds.
|
inline |
Gets the internally stored system dependent time in ticks.
|
inline |
Sets the actual point in time as the value of this instance.
|
inline |
|
inline |
Sets the internal value by converting the given DateTime. The conversion is dependent on time zone and system clock setting of the host.
dateTime | A DateTime instance to read and convert the ticks from. |
|
inline |
Sets the internal value by converting the given milliseconds since January 1, 1970, 00:00:00 GMT. The conversion is dependent on time zone and system clock setting of the host.
epochMillis | The milliseconds in the epoch to convert. |
|
inline |
Sets this objects' value to the value specified in ticks.
value | The ticks value to set |
Returns the time span between the value represented by this instance and the given TickWatch. If the given TickWatch represents an earlier point in time, the result is positive.
Note: Attention: The object returned is a temporary object, deemed to be reused by other interface methods of this instance. Therefore, it must be used only until subsequent method invocations on this instance are performed (hence, also not thread safe!) Use Since(Ticks result, Ticks result) to provide a dedicated external result instance.
olderTime | The value to compare this instance with |
Returns the time span between the value represented by this instance and the given TickWatch. If the given TickWatch represents an earlier point in time, the result is positive.
olderTime | The value to compare this instance with |
result | The Ticks object to store the result in. If null, this is created. |
|
inline |
Subtracts the point in time or time span represented by the given Ticks instance from this instance.
value | The ticks to subtract. |
|
inline |
|
inline |
Returns a String that represents this object formatted according to formatString. For this, an object of .Net type DateTime is created and its ToString method is invoked. Hence, the format string follows the syntax defined for class DateTime.
formatString | The format string |
fProvider | The format provider |
|
static |
The time (in ticks) when the ticker library containing the ticker (ALIB) was initialized. This might be useful to measure the time since the process was started.
|
static |
The Frequency of the internal tick timer. The Frequency gives you an indication of the accuracy of the time (At least if the underlying system library is reasonably well working in this respect). And this is the reason why it is published with this field. This value does not necessarily correspond to the number of ticks per second that you get from this classes Raw method.