sourcestats: don't save stratum for all samples

Save stratum only from the last accumulated sample as only that is
currently needed.
This commit is contained in:
Miroslav Lichvar 2018-08-01 16:19:37 +02:00
parent 05078e4252
commit 108d112272

View file

@ -174,9 +174,8 @@ struct SST_Stats_Record {
time of the measurements */ time of the measurements */
double root_dispersions[MAX_SAMPLES]; double root_dispersions[MAX_SAMPLES];
/* This array contains the strata that were associated with the sources /* The stratum from the last accumulated sample */
at the times the samples were generated */ int stratum;
int strata[MAX_SAMPLES];
/* The leap status from the last accumulated sample */ /* The leap status from the last accumulated sample */
NTP_Leap leap; NTP_Leap leap;
@ -323,7 +322,7 @@ SST_AccumulateSample(SST_Stats inst, struct timespec *sample_time,
inst->peer_dispersions[m] = peer_dispersion; inst->peer_dispersions[m] = peer_dispersion;
inst->root_delays[m] = root_delay; inst->root_delays[m] = root_delay;
inst->root_dispersions[m] = root_dispersion; inst->root_dispersions[m] = root_dispersion;
inst->strata[m] = stratum; inst->stratum = stratum;
inst->leap = leap; inst->leap = leap;
if (inst->peer_delays[n] < inst->fixed_min_delay) if (inst->peer_delays[n] < inst->fixed_min_delay)
@ -660,7 +659,7 @@ SST_GetSelectionData(SST_Stats inst, struct timespec *now,
i = get_runsbuf_index(inst, inst->best_single_sample); i = get_runsbuf_index(inst, inst->best_single_sample);
j = get_buf_index(inst, inst->best_single_sample); j = get_buf_index(inst, inst->best_single_sample);
*stratum = inst->strata[get_buf_index(inst, inst->n_samples - 1)]; *stratum = inst->stratum;
*leap = inst->leap; *leap = inst->leap;
*std_dev = inst->std_dev; *std_dev = inst->std_dev;
@ -869,7 +868,7 @@ SST_SaveToFile(SST_Stats inst, FILE *out)
inst->root_delays[j], inst->root_delays[j],
inst->root_dispersions[j], inst->root_dispersions[j],
1.0, /* used to be inst->weights[i] */ 1.0, /* used to be inst->weights[i] */
inst->strata[j]); inst->stratum /* used to be an array */);
} }
@ -914,7 +913,7 @@ SST_LoadFromFile(SST_Stats inst, FILE *in)
&(inst->root_delays[i]), &(inst->root_delays[i]),
&(inst->root_dispersions[i]), &(inst->root_dispersions[i]),
&weight, /* not used anymore */ &weight, /* not used anymore */
&(inst->strata[i])) != 10)) { &inst->stratum) != 10)) {
/* This is the branch taken if the read FAILED */ /* This is the branch taken if the read FAILED */
@ -962,7 +961,7 @@ SST_DoSourceReport(SST_Stats inst, RPT_SourceReport *report, struct timespec *no
report->orig_latest_meas = inst->orig_offsets[j]; report->orig_latest_meas = inst->orig_offsets[j];
report->latest_meas = inst->offsets[i]; report->latest_meas = inst->offsets[i];
report->latest_meas_err = 0.5*inst->root_delays[j] + inst->root_dispersions[j]; report->latest_meas_err = 0.5*inst->root_delays[j] + inst->root_dispersions[j];
report->stratum = inst->strata[j]; report->stratum = inst->stratum;
/* Align the sample time to reduce the leak of the receive timestamp */ /* Align the sample time to reduce the leak of the receive timestamp */
last_sample_time = inst->sample_times[i]; last_sample_time = inst->sample_times[i];