문제

I'm trying to figure out how to find how much time is my application running, but all I can find are:

Clock()
timersub()

and some similar stuff, but I can't use them, ....

what must I include in my code so I can use them?

like I include:

using System.Collections.Generic;

so I can use:

List<int> ints = new List<int>();

and if I do:

#include <time.h> // I get: Wrong preprocessor directive

Also I need floating point since start up and what I do get from:

System.DateTime.Now; // - not float but sealed struct
도움이 되었습니까?

해결책

I normally use the StopWatch class

using System.Diagnostics;

Stopwatch sw = Stopwatch.StartNew();

Do Stuff...

sw.Stop();
TimeSpan elapsedTime = sw.Elapsed;

다른 팁

Normally if you want to time an operation you would use the StopWatch class.

It is available in Mono as well and should work just fine on Linux.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top