Lines Matching +full:sample +full:- +full:time

1 // SPDX-License-Identifier: GPL-2.0-only
15 #include <time.h>
24 #define MAX_PRECISION 500e-9
25 #define MAX_FREQ_ERROR 0.02e-6
26 #define MAX_STDDEV 50e-9
32 struct sample { struct
34 double time; member
45 return ts1->tv_sec - ts2->tv_sec + (ts1->tv_nsec - ts2->tv_nsec) / 1e9; in diff_timespec()
48 static double get_sample(struct sample *sample) in get_sample() argument
59 ts1.tv_sec -= mono_raw_base; in get_sample()
60 ts2.tv_sec -= mono_base; in get_sample()
61 ts3.tv_sec -= mono_raw_base; in get_sample()
64 if (delay <= 1e-9) { in get_sample()
65 i--; in get_sample()
70 sample->offset = diff_timespec(&ts2, &ts1); in get_sample()
71 sample->offset -= delay / 2.0; in get_sample()
72 sample->time = ts1.tv_sec + ts1.tv_nsec / 1e9; in get_sample()
85 txc.time.tv_sec = 0; in reset_ntp_error()
86 txc.time.tv_usec = 0; in reset_ntp_error()
103 txc.freq = (1e6 * freq - user_hz * tick_offset) * (1 << 16); in set_frequency()
111 static void regress(struct sample *samples, int n, double *intercept, in regress()
120 x = samples[i].time; in regress()
129 *slope = (xy_sum - x_sum * y_sum / n) / (x2_sum - x_sum * x_sum / n); in regress()
130 *intercept = (y_sum - *slope * x_sum) / n; in regress()
135 x = samples[i].time; in regress()
137 r = fabs(x * *slope + *intercept - y); in regress()
148 struct sample samples[SAMPLES]; in run_test()
181 freq_error1 = slope * (1.0 - mono_freq_offset) - mono_freq_offset - in run_test()
186 freq_error2 = slope * (1.0 - mono_freq_offset) - mono_freq_offset - in run_test()
206 struct sample sample; in init_test() local
224 precision = get_sample(&sample) / 2.0; in init_test()
249 for (i = 2; i >= 0; i--) { in main()
251 freq_base = (rand() % (1 << 24) - (1 << 23)) / 65536e6; in main()
252 freq_step = 10e-6 * (1 << (6 * i)); in main()