0

I want to record the amount of time it takes to execute my custom method, but I have never worked with the timer class or methods before, I know I'm doing something wrong, .

Here's what I have.

System.Timers.Timer Time;
int Mili = 0 ;

data = Generate();

Time.Enabled = true;
BSort= BubbleSort(data);

Time.Enabled = false;
Rob
  • 26,483
  • 15
  • 80
  • 92
userID
  • 9
  • 3

1 Answers1

9

A timer is for a periodic event. You should look at the Stopwatch class.

var sw = Stopwatch.StartNew();

// your code ...

// sw.Stop(), sw.Elapsed, etc.
Daniel A. White
  • 181,601
  • 45
  • 354
  • 430