Lines Matching +full:double +full:- +full:precision

1 // SPDX-License-Identifier: GPL-2.0-only
24 #define MAX_PRECISION 500e-9
25 #define MAX_FREQ_ERROR 0.02e-6
26 #define MAX_STDDEV 50e-9
33 double offset;
34 double time;
40 static double precision; variable
41 static double mono_freq_offset;
43 static double diff_timespec(struct timespec *ts1, struct timespec *ts2) in diff_timespec()
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()
50 double delay, mindelay = 0.0; in get_sample()
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()
94 static void set_frequency(double freq) in set_frequency()
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()
112 double *slope, double *r_stddev, double *r_max) in regress()
114 double x, y, r, x_sum, y_sum, xy_sum, x2_sum, r2_sum; 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()
137 r = fabs(x * *slope + *intercept - y); in regress()
146 static int run_test(int calibration, double freq_base, double freq_step) in run_test()
149 double intercept, slope, stddev1, max1, stddev2, max2; in run_test()
150 double freq_error1, freq_error2; 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()
224 precision = get_sample(&sample) / 2.0; in init_test()
225 printf("CLOCK_MONOTONIC_RAW+CLOCK_MONOTONIC precision: %.0f ns\t\t", in init_test()
226 1e9 * precision); in init_test()
228 if (precision > MAX_PRECISION) in init_test()
229 ksft_exit_skip("precision: %.0f ns > MAX_PRECISION: %.0f ns\n", in init_test()
230 1e9 * precision, 1e9 * MAX_PRECISION); in init_test()
240 double freq_base, freq_step; in main()
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()