Cleanup sourcestats code a bit

This commit is contained in:
Miroslav Lichvar 2010-08-10 15:35:17 +02:00
parent 3b4e4b785d
commit d841c86a6e

View file

@ -48,9 +48,6 @@
2000ppm, which would be pretty bad */ 2000ppm, which would be pretty bad */
#define WORST_CASE_FREQ_BOUND (2000.0/1.0e6) #define WORST_CASE_FREQ_BOUND (2000.0/1.0e6)
/* Day number of 1 Jan 1970 */
#define MJD_1970 40587
/* ================================================== */ /* ================================================== */
static LOG_FileID logfileid; static LOG_FileID logfileid;
@ -210,7 +207,7 @@ move_stats_entry(SST_Stats inst, int src, int dest)
For now, just discard the oldest sample. */ For now, just discard the oldest sample. */
static void static void
prune_register(SST_Stats inst, int new_oldest, int *bad_points) prune_register(SST_Stats inst, int new_oldest)
{ {
int i, j; int i, j;
@ -219,13 +216,11 @@ prune_register(SST_Stats inst, int new_oldest, int *bad_points)
} }
for (i=0, j=new_oldest; j<inst->n_samples; j++) { for (i=0, j=new_oldest; j<inst->n_samples; j++) {
if (!bad_points || !bad_points[j]) {
if (j != i) { if (j != i) {
move_stats_entry(inst, j, i); move_stats_entry(inst, j, i);
} }
i++; i++;
} }
}
inst->n_samples = i; inst->n_samples = i;
} }
@ -240,12 +235,9 @@ SST_AccumulateSample(SST_Stats inst, struct timeval *sample_time,
int stratum) int stratum)
{ {
int n; int n;
#if 0
double root_distance;
#endif
if (inst->n_samples == MAX_SAMPLES) { if (inst->n_samples == MAX_SAMPLES) {
prune_register(inst, 1, NULL); prune_register(inst, 1);
} }
n = inst->n_samples; n = inst->n_samples;
@ -357,7 +349,6 @@ SST_DoNewRegression(SST_Stats inst)
double peer_distances[MAX_SAMPLES]; double peer_distances[MAX_SAMPLES];
double weights[MAX_SAMPLES]; double weights[MAX_SAMPLES];
int bad_points[MAX_SAMPLES];
int degrees_of_freedom; int degrees_of_freedom;
int best_start; int best_start;
double est_intercept, est_slope, est_var, est_intercept_sd, est_slope_sd; double est_intercept, est_slope, est_var, est_intercept_sd, est_slope_sd;
@ -396,10 +387,6 @@ SST_DoNewRegression(SST_Stats inst)
&est_intercept_sd, &est_slope_sd, &est_intercept_sd, &est_slope_sd,
&best_start, &nruns, &degrees_of_freedom); &best_start, &nruns, &degrees_of_freedom);
/* This is a legacy of when the regression routine found outliers
for us. We don't use it anymore. */
memset((void *) bad_points, 0, MAX_SAMPLES * sizeof(int));
if (regression_ok) { if (regression_ok) {
old_skew = inst->skew; old_skew = inst->skew;
@ -441,7 +428,7 @@ SST_DoNewRegression(SST_Stats inst)
best_start, nruns); best_start, nruns);
} }
prune_register(inst, best_start, bad_points); prune_register(inst, best_start);
} else { } else {
#if 0 #if 0
@ -721,7 +708,7 @@ SST_LoadFromFile(SST_Stats inst, FILE *in)
double weight; double weight;
if (fgets(line, sizeof(line), in) && if (fgets(line, sizeof(line), in) &&
(sscanf(line, "%d", &inst->n_samples) == 1)) { (sscanf(line, "%u", &inst->n_samples) == 1) && inst->n_samples <= MAX_SAMPLES) {
line_number = 2; line_number = 2;