ardsrk
ardsrk

Reputation: 2447

Finding out the time taken to execute a 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 reason it always returns zero. Am I missing something here or are there alternatives?

Upvotes: 0

Views: 612

Answers (2)

Ian
Ian

Reputation: 34539

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

Upvotes: 1

Ashish
Ashish

Reputation: 8529

Try this out :

clock_t start , end ;

start = clock();

funct();

end = clock();

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

Upvotes: 0

Related Questions