2

What are the advantages of using a StopWatch instead using Environment.TickCount?

I usually get the elapsed time using the following mechanism:

int ini = Environment.TickCount
// perform some operations
int elapsedMilliseconds = Environment.TickCount - ini;

But some SO experts recommended using an StopWatch:

StopWatch sw = new StopWatch();
sw.Start();
// perform some operations
sw.Stop();
int elapsedMilliseconds = sw.EllpasedMillseconds;

Is just a OOP thing, or maybe I'm measuring the elapsed time in a wrong way?

Daniel Peñalba
  • 30,507
  • 32
  • 137
  • 219

0 Answers0