Stopwatch
When developing, there are times when the actual code needs execution time.
This is the function used at that time.
namespace
System.Diagnostics
How to use
Instance creation
You can use new Stopwatch().
// Instance creation
Stopwatch s = new Stopwatch();
Function
- Start : Start measurement
- Stop : End measurement
- ElapsedMilliseconds : Measured time ms
- Reset : Reset time
- Restart : Reset time and restart
s.Start();
Tread.Sleep(1000); // Actual source code part
s.Stop();
Console.WriteLine(s.ElapsedMilliseconds);
Conclusion
I wrote a very brief example.
You only need to know Start, Stop, ElapsedMilliseconds.