[ntp:questions] Re: Post processing of NTP data...
Richard B. Gilbert
rgilbert88 at comcast.net
Fri Sep 30 16:11:43 UTC 2005
John Pettitt wrote:
>Brad Knowles wrote:
>
>
>
>>At 4:53 PM +0000 2005-09-29, John Pettitt wrote:
>>
>>
>>
>>> I don't agree with Brad that 10ms is as good as it gets,
>>>
>>>
>> If your HZ= setting is 100, then 10ms is, by definition, as good
>>as it gets. At least, when it comes to measuring short-term single
>>event clock timing matters.
>>
>>
>>
>>
>No HZ is not the gating factor because the system returns a time based
>on the processor cycle count (*) On my FreeBSD Celeron box a tight
>loop calling gettimeofday() shows an average increment of 1.4
>microseconds per loop and yes the values change on every call.
>
>John
>(*) on machines with APM enabled all bets are off because the CPU
>frequency is not stable.
>_______________________________________________
>questions mailing list
>questions at lists.ntp.isc.org
>https://lists.ntp.isc.org/mailman/listinfo/questions
>
>
>
I just grabbed the following bit of code off the net (version shown is
minus a time burning nested loop).
*****************************************************************************
* FILE: gettime.ex.c
* DESCRIPTION: Demonstrates use of the gettimeofday function
* LAST REVISED: 01/09/96 Blaise Barney
*****************************************************************************/
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
#define ARRAY_SIZE 1000
#define SEED 1995
float a[ARRAY_SIZE][ARRAY_SIZE];
float b[ARRAY_SIZE][ARRAY_SIZE];
float c[ARRAY_SIZE][ARRAY_SIZE];
struct timeval start_time, end_time;
main()
{
int i, j;
int total_usecs;
/* First, call gettimeofday() to get start time */
gettimeofday(&start_time, (struct timeval*)0);
/* Time wasting nested loops removed. */
/* Now call gettimeofday() to get end time */
gettimeofday(&end_time, (struct timeval*)0); /* after time */
/* Print the execution time */
total_usecs = (end_time.tv_sec-start_time.tv_sec) * 1000000 +
(end_time.tv_usec-start_time.tv_usec);
}
I compiled, linked, and ran it on a Sun Ultra 10 with Solaris 8 and got
a elapsed times of one or two microseconds in a dozen tries. So 10ms
is not necessarily "as good as it gets" on Solaris either.
More information about the questions
mailing list