Mail Archives: cygwin/2002/01/24/16:49:05
> > I adapted the code to find exactly the minimum time slice, and not "how well
> > 1ms of retard is seen" (it was a 0ns or 15000ns, this is always 15000ns;
> > moreover printf is out of the "timing" section):
> isn't the time slice about 10ms. ?
Actually is between 15 and 16ms:
try 1: 437687512 - 437703512 = 16000
try 2: 437703512 - 437719512 = 16000
try 3: 437719512 - 437734512 = 15000
try 4: 437734512 - 437750512 = 16000
try 5: 437750512 - 437766512 = 16000
try 6: 437766512 - 437781512 = 15000
try 7: 437781512 - 437797512 = 16000
try 8: 437797512 - 437812512 = 15000
try 9: 437812512 - 437828512 = 16000
try 10: 437828512 - 437844512 = 16000
try 11: 437844512 - 437859512 = 15000
try 12: 437859512 - 437875512 = 16000
try 13: 437875512 - 437891512 = 16000
try 14: 437891512 - 437906512 = 15000
try 15: 437906512 - 437922512 = 16000
try 16: 437922512 - 437937512 = 15000
try 17: 437937512 - 437953512 = 16000
try 18: 437953512 - 437969512 = 16000
try 19: 437969512 - 437984512 = 15000
try 20: 437984512 - 438000512 = 16000
Just try this source:
#include <sys/time.h>
#define TV2LONG(t) ((unsigned long)t.tv_sec)*1000000+((unsigned long)t.tv_usec)
int main() {
struct timeval tp;
unsigned long a, b;
unsigned int n = 1;
for(n=1; n<=20; n++) {
gettimeofday(&tp, 0);
a = TV2LONG(tp);
do {
gettimeofday(&tp, 0);
} while((b = TV2LONG(tp)) <= a);
printf("try %2d: %ld - %ld = %ld\n", n, a, b, b-a);
}
gettimeofday(&tp, 0);
a = TV2LONG(tp);
usleep(1000000);
gettimeofday(&tp, 0);
b = TV2LONG(tp);
printf("sleep: %ld - %ld = %ld usec\n", a, b, b-a);
}
--
Lapo 'Raist' Luchini
lapo AT lapo DOT it (PGP & X.509 keys available)
http://www.lapo.it (ICQ UIN: 529796)
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -