Usenet comp.os.linux.alpha (1997-2013)
 help / color / mirror / Atom feed
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: gettimeofday resolution
Date: 2000/03/23	[thread overview]
Message-ID: <38DA191A.C7708BAB@ife.ee.ethz.ch> (raw)

I use gettimeofday for time measurement.
On my PWS500a with RH 6.1, kernel 2.2.12, this works fine, giving me
microsecond resolution.
A test on UP2000 with SuSE 6.1 and 2.2.13 kernel returns the time with
1ms jumps

The following program outputs 1 or 2 us on PWS/RH and 980 on UP2000/SuSE

could somebody please test this with different configs and help me find
the reason for the difference?

Thanks
Alex

#include <time.h>                               // for gettimeofday
#include <sys/time.h>
#include <stdio.h>

int main(int argc, char**argv)
{
  struct timeval  tv1, tv2;
  
  gettimeofday(&tv1, NULL);
  do {
    gettimeofday(&tv2, NULL);
  } while (tv1.tv_usec == tv2.tv_usec);

  printf("Difference: %d us\n", tv2.tv_usec - tv1.tv_usec + 
         1000000 * (tv2.tv_sec - tv1.tv_sec));

  return 0;
}



             reply	other threads:[~2000-03-23  5:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-23  5:00 Alex Rhomberg [this message]
2000-03-23  5:00 ` gettimeofday resolution Alex Rhomberg
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox