Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Diagnostics.​Stopwatch
Assembly: System.Runtime
Inheritance: object → Stopwatch
Provides a set of methods and properties that you can use to accurately measure elapsed time.
Fields and Constants
public static readonly
long
Frequency
Gets the frequency of the timer as the number of ticks per second. This field is read-only.
public static readonly
bool
IsHighResolution
Indicates whether the timer is based on a high-resolution performance counter. This field is read-only.
Properties
public
TimeSpan
Elapsed
Gets the total elapsed time measured by the current instance.
public
long
ElapsedMilliseconds
Gets the total elapsed time measured by the current instance, in milliseconds.
public
long
ElapsedTicks
Gets the total elapsed time measured by the current instance, in timer ticks.
public
bool
IsRunning
Gets a value indicating whether the <see cref="T:System.Diagnostics.Stopwatch" /> timer is running.
Methods
public
void
Reset​()
Stops time interval measurement and resets the elapsed time to zero.
public
void
Restart​()
Stops time interval measurement, resets the elapsed time to zero, and starts measuring elapsed time.
public
void
Start​()
Starts, or resumes, measuring elapsed time for an interval.
public
void
Stop​()
Stops measuring elapsed time for an interval.
public
string
ToString​() Returns The elapsed time string in the same format used by <see cref="M:System.TimeSpan.ToString" /> .
Returns the <see cref="P:System.Diagnostics.Stopwatch.Elapsed" /> time as a string.
public
bool
Equals​(object obj)
Inherited from object
obj
The object to compare with the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
Determines whether the specified object is equal to the current object.
protected
void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public
int
GetHashCode​()
Inherited from object
Returns A hash code for the current object.
Serves as the default hash function.
public
Type
GetType​()
Inherited from object
Returns The exact runtime type of the current instance.
Gets the <see cref="T:System.Type" /> of the current instance.
protected
object
MemberwiseClone​()
Inherited from object
Returns A shallow copy of the current <see cref="T:System.Object" /> .
Creates a shallow copy of the current <see cref="T:System.Object" /> .