Follow these steps to find out the number of clock ticks and CPU seconds required to run a function:
- Define two variables of the clock_t data type for saving processor time.
- Invoke the clock() function to discern the number of clock ticks elapsed from the time the program is invoked. The clock ticks are saved in one of the variables.
- Invoke a function whose processing time has to be established.
- Again, invoke the clock() function and then save the returned number of clock ticks to another variable.
- Subtract the number of clock ticks in the two variables to discern the number of clock ticks required to execute the function.
- Divide the number of clock ticks returned in the preceding steps by CLOCKS_PER_SEC to identify the number ...