Code Snippet
Have a look at this: https://stackoverflow.com/questions/17167949/how-to-use-timer-in-c
Update
I've turned the code snippet into a working program:
#include <time.h>
#include <stdio.h>
int main ()
{
int iterations = 0;
int msec = 0, trigger = 10; /* 10ms */
clock_t before = clock ();
do
{
printf("doing some heavy work here...\n");
for (int i = 0; i < 1000000; i++) /* no operation */;
/* Do something to busy the CPU just here while you drink a coffee
* Be sure this code will not take more than `trigger` ms */
clock_t difference = clock () - before;
msec = difference * 1000 / CLOCKS_PER_SEC;
iterations++;
} while (msec < trigger);
printf ("Time taken %d seconds %d milliseconds (%d iterations)\n", msec / 1000, msec % 1000, iterations);
return 0;
}