Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- class Program
- {
- static void Main()
- {
- // Create a Stopwatch instance
- Stopwatch stopwatch = new Stopwatch();
- // Start measuring time
- stopwatch.Start();
- // Call the method you want to measure
- MyMethodToMeasure();
- // Stop measuring time
- stopwatch.Stop();
- // Get the elapsed time in milliseconds
- long elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
- Console.WriteLine($"Execution time: {elapsedMilliseconds} ms");
- }
- static void MyMethodToMeasure()
- {
- // The method you want to measure
- for (int i = 0; i < 1000000; i++)
- {
- // Do some work
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement