I have threads running, the threaded function contains a loop and iterates for a certain amount of time.
Per exemple:
void *start(void *p) // This function is called at the thread creation
{
int i = 0;
while (i < 10){
i++;
}
} // NOTE THAT THIS FUNCTION IS AN EXAMPLE, the iteration can be small or high.
How may I monitor the time spent between two iterations? (Taking into consideration the fact that I have many threads running it at the same time)
I have heard of the clock() function, and the following operation to determine the time spent between two clock() outputs:
(double)(begin - end) / CLOCKS_PER_SEC;
How may I retrieve such information in an efficient manner?