C

Asked • 06/12/19

Execution time of C program?

I have a C program that aims to be run in parallel on several processors. I need to be able to record the execution time (which could be anywhere from 1 second to several minutes). I have searched for answers, but they all seem to suggest using the `clock()` function, which then involves calculating the number of clocks the program took divided by the `Clocks_per_second` value.I'm not sure how the `Clocks_per_second` value is calculated? In Java, I just take the current time in milliseconds before and after execution. Is there a similar thing in C? I've had a look, but I can't seem to find a way of getting anything better than a second resolution. I'm also aware a profiler would be an option, but am looking to implement a timer myself.Thanks

1 Expert Answer

By:

Charles B. answered • 06/15/19

Tutor
4.3 (3)

Passionate Professional Programmer

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.