This is a little off-topic, but I am afraid I do not fully understand the code.
My understanding of the purpose of the initial loop
Quote:
Originally Posted by otheus
Code:
for (i = 0; i < 1000; ++i) {
usleep(10);
last=time(NULL);
if (last > start) break;
}
|
is to start the whole measurement at the point of change of the second. Right?
Next,
we have two loops: first run 8750000 times, given the maxloop value of 1000000,
Then we run loop up to 1250000 times where every 100th iteration we check for time and if second changed, we break out
Quote:
Originally Posted by otheus
Code:
stop=time(NULL);
for (i = maxloop - maxloop/8; i < maxloop; ++i) {
if ( !(i % estimate) ) {
last=time(NULL);
if (last > stop) break;
stop=last;
}
/* repeat semaphore opts */
if ((sid = semget(key, NSEMS, IPC_CREAT | 0777)) == -1) {
perror("Can Not Get Semaphore ID");
}
if (semctl(sid, NSEMS, GETALL, vals) == -1) {
perror("Can Not Get Semaphore Values");
}
}
stop=last;
|
What is this technique of checking every Nth iteration for? why not check time every iteration? is it because this would add to many extra time calls and muddy the measurements?
Your clarification would be appreciated.