Creating an Instance of a Stopwatch

suggest change

A Stopwatch instance can measure elapsed time over several intervals with the total elapsed time being all individual intervals added together. This gives a reliable method of measuring elapsed time between two or more events.

Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();

double d = 0;
for (int i = 0; i < 1000 * 1000 * 1000; i++)
{
    d += 1;
}

stopWatch.Stop();
Console.WriteLine("Time elapsed: {0:hh\\:mm\\:ss\\.fffffff}", stopWatch.Elapsed);

Stopwach is in System.Diagnostics so you need to add using System.Diagnostics; to your file.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Stopwatches:
* Creating an Instance of a Stopwatch

Table Of Contents
17 Regex
19 Arrays
21 Enum
22 Tuples
24 GUID
27 Looping
36 Casting
46 Methods
88 Events
92 Structs
104 Indexer
106 Stream
107 Timers
108 Stopwatches
109 Threading
127 Caching
135 Pointers
147 C# Script