开发者

Finding out the time taken to execute a function

开发者 https://www.devze.com 2022-12-10 12:35 出处:网络
I wrote a function to match fingerprint templates using VC++.NET. Now I want to know the time it takes to execute the function.

I wrote a function to match fingerprint templates using VC++.NET.

Now I want to know the time it takes to execute the function.

I tried surrounding the function call statement with clock ( Standard C Library ) and computing the difference in the values returned. For some re开发者_如何学运维ason it always returns zero. Am I missing something here or are there alternatives?


Can you not just used the System.Diagnostics.Stopwatch? I'm assuming its both the same in VC++.NET and C#.NET.

If you can then you just need VC++ equivalent of :

Stopwatch sw = Stopwatch.StartNew()
Func();
sw.Stop();

Might want to check out Stopwatch


Try this out :

clock_t start , end ;

start = clock();

funct();

end = clock();

double exe_time = (end - start) / CLOCKS_PER_SEC; // in second

0

精彩评论

暂无评论...
验证码 换一张
取 消