Gorgon
Show / Hide Table of Contents

Class GorgonTimerQpc

An implementation of the IGorgonTimer interface.

Inheritance
object
GorgonTimerQpc
Implements
IGorgonTimer
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
Namespace: Gorgon.Timing
Assembly: Gorgon.Windows.dll
Syntax
public sealed class GorgonTimerQpc : IGorgonTimer
Remarks

This implementation uses the Query Performance Counter. It provides accuracy of 1 microsecond.

caution

Issues

On older processors this functionality may not be supported at all. If Gorgon can't detect support for this type of timer, it will throw an exception. In order to avoid this, use the SupportsQpc() static method on this class to determine if the system will support the timer. This should not be an issue with a reasonably modern system.

This is an issue on systems with Windows versions before Windows Vista because multi-core systems may not report the correct time stamp. Since Gorgon requires Windows 10 at minimum, this should not be an issue.

There may be a performance hit using this timer, depending on your operating system version and hardware.

For a comprehensive overview of the Qpc timer, go to https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx.

Properties

| Edit this page View Source

Days

Property to return the number of days elapsed since the timer was started.

Declaration
public double Days { get; }
Property Value
Type Description
double
| Edit this page View Source

Hours

Property to return the number of hours elapsed since the timer was started.

Declaration
public double Hours { get; }
Property Value
Type Description
double
| Edit this page View Source

IsHighResolution

Property to return whether this timer has a resolution of less than 1 millisecond or not.

Declaration
public bool IsHighResolution { get; }
Property Value
Type Description
bool
| Edit this page View Source

Microseconds

Property to return the number of microseconds elapsed since the timer was started.

Declaration
public double Microseconds { get; }
Property Value
Type Description
double
| Edit this page View Source

Milliseconds

Property to return the number of milliseconds elapsed since the timer was started.

Declaration
public double Milliseconds { get; }
Property Value
Type Description
double
| Edit this page View Source

Minutes

Property to return the number of minutes elapsed since the timer was started.

Declaration
public double Minutes { get; }
Property Value
Type Description
double
| Edit this page View Source

Seconds

Property to return the number of seconds elapsed since the timer was started.

Declaration
public double Seconds { get; }
Property Value
Type Description
double
| Edit this page View Source

Ticks

Property to return the number of ticks since the timer was started.

Declaration
public long Ticks { get; }
Property Value
Type Description
long

Methods

| Edit this page View Source

Reset()

Function to reset the timer.

Declaration
public void Reset()
| Edit this page View Source

SupportsQpc()

Function to return whether the system supports the query performance counter.

Declaration
public static bool SupportsQpc()
Returns
Type Description
bool

true if the system supports the timer, false if it does not.

Implements

IGorgonTimer

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author