I was trying to measure the execution times of the c programs for efficiency by executing the .exe as process in C# and finding the time with TotalProcessorTime property.
But the problem i have been facing is that, when i run the process for more than a couple times, the TotalProcessorTime property is turned to zero.Even though the program executes completely.
I tried to create a separate thread and run the process on that, but
even then same problem persists.

Can anyone tell me why ? or if there is better way to measure the execution time.

P.S Stopwatch,Timer are much worse, they have a very large variation.

Thanks ddanbe for the above link. I solved part of the problem.I am able to get almost consistent timings for the execution time. But the ExecutionStopwatch gives zero as the execution times most of the time.
I tried running it on the same thread and on different threads,
but the result is the same.
Is there any reason the time can be zero ?

I will be really grateful if anyone helps..................

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.