mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 07:05:06 -05:00
quantiles: add functions to get max k and min step
This commit is contained in:
@@ -199,8 +199,8 @@ HCL_ProcessReadings(HCL_Instance clock, int n_readings, struct timespec tss[][3]
|
|||||||
|
|
||||||
local_prec = LCL_GetSysPrecisionAsQuantum();
|
local_prec = LCL_GetSysPrecisionAsQuantum();
|
||||||
|
|
||||||
low_delay = QNT_GetQuantile(clock->delay_quants, DELAY_QUANT_MIN_K);
|
low_delay = QNT_GetQuantile(clock->delay_quants, QNT_GetMinK(clock->delay_quants));
|
||||||
high_delay = QNT_GetQuantile(clock->delay_quants, DELAY_QUANT_MAX_K);
|
high_delay = QNT_GetQuantile(clock->delay_quants, QNT_GetMaxK(clock->delay_quants));
|
||||||
low_delay = MIN(low_delay, high_delay);
|
low_delay = MIN(low_delay, high_delay);
|
||||||
high_delay = MAX(high_delay, low_delay + local_prec);
|
high_delay = MAX(high_delay, low_delay + local_prec);
|
||||||
|
|
||||||
|
|||||||
16
quantiles.c
16
quantiles.c
@@ -193,6 +193,22 @@ QNT_GetMinK(QNT_Instance inst)
|
|||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
QNT_GetMaxK(QNT_Instance inst)
|
||||||
|
{
|
||||||
|
return inst->min_k + (inst->n_quants / inst->repeat) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
double
|
||||||
|
QNT_GetMinStep(QNT_Instance inst)
|
||||||
|
{
|
||||||
|
return inst->min_step;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
double
|
double
|
||||||
QNT_GetQuantile(QNT_Instance inst, int k)
|
QNT_GetQuantile(QNT_Instance inst, int k)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ extern void QNT_DestroyInstance(QNT_Instance inst);
|
|||||||
extern void QNT_Reset(QNT_Instance inst);
|
extern void QNT_Reset(QNT_Instance inst);
|
||||||
extern void QNT_Accumulate(QNT_Instance inst, double value);
|
extern void QNT_Accumulate(QNT_Instance inst, double value);
|
||||||
extern int QNT_GetMinK(QNT_Instance inst);
|
extern int QNT_GetMinK(QNT_Instance inst);
|
||||||
|
extern int QNT_GetMaxK(QNT_Instance inst);
|
||||||
|
extern double QNT_GetMinStep(QNT_Instance inst);
|
||||||
extern double QNT_GetQuantile(QNT_Instance inst, int k);
|
extern double QNT_GetQuantile(QNT_Instance inst, int k);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ test_unit(void)
|
|||||||
inst = QNT_CreateInstance(min_k, max_k, q, r, 1e-9);
|
inst = QNT_CreateInstance(min_k, max_k, q, r, 1e-9);
|
||||||
|
|
||||||
TEST_CHECK(min_k == QNT_GetMinK(inst));
|
TEST_CHECK(min_k == QNT_GetMinK(inst));
|
||||||
|
TEST_CHECK(max_k == QNT_GetMaxK(inst));
|
||||||
|
TEST_CHECK(fabs(QNT_GetMinStep(inst) - 1e-9) < 1e-12);
|
||||||
|
|
||||||
for (j = 0; j < 3000; j++) {
|
for (j = 0; j < 3000; j++) {
|
||||||
x = TST_GetRandomDouble(0.0, 2e-6);
|
x = TST_GetRandomDouble(0.0, 2e-6);
|
||||||
|
|||||||
Reference in New Issue
Block a user