AP_HAL_Linux: rename min, max and avg fields

These were probably named otherwise in order not to conflict with
min/max macros from math.h. We don't have this problem anymore.
This commit is contained in:
Lucas De Marchi 2016-05-27 09:55:50 -03:00
parent b8e3e549c7
commit 4a18108600
2 changed files with 14 additions and 14 deletions

View File

@ -77,7 +77,7 @@ void Perf::_debug_counters()
"max: %llu\t" "max: %llu\t"
"avg: %.4f\t" "avg: %.4f\t"
"stddev: %.4f\n", "stddev: %.4f\n",
c.name, c.count, c.least, c.most, c.mean, sqrt(c.m2)); c.name, c.count, c.min, c.max, c.avg, sqrt(c.m2));
} else { } else {
fprintf(stderr, "%-30s\t" fprintf(stderr, "%-30s\t"
"count: %llu\n", "count: %llu\n",
@ -161,22 +161,22 @@ void Perf::end(Util::perf_counter_t pc)
perf.count++; perf.count++;
perf.total += elapsed; perf.total += elapsed;
if (perf.least > elapsed) { if (perf.min > elapsed) {
perf.least = elapsed; perf.min = elapsed;
} }
if (perf.most < elapsed) { if (perf.max < elapsed) {
perf.most = elapsed; perf.max = elapsed;
} }
/* /*
* Maintain mean and variance of interval in nanoseconds * Maintain avg and variance of interval in nanoseconds
* Knuth/Welford recursive mean and variance of update intervals (via Wikipedia) * Knuth/Welford recursive avg and variance of update intervals (via Wikipedia)
* Same implementation of PX4. * Same implementation of PX4.
*/ */
const double delta_intvl = elapsed - perf.mean; const double delta_intvl = elapsed - perf.avg;
perf.mean += (delta_intvl / perf.count); perf.avg += (delta_intvl / perf.count);
perf.m2 += (delta_intvl * (elapsed - perf.mean)); perf.m2 += (delta_intvl * (elapsed - perf.avg));
perf.start = 0; perf.start = 0;
perf.lttng.end(perf.name); perf.lttng.end(perf.name);

View File

@ -37,7 +37,7 @@ public:
Perf_Counter(perf_counter_type type_, const char *name_) Perf_Counter(perf_counter_type type_, const char *name_)
: name{name_} : name{name_}
, type{type_} , type{type_}
, least{ULONG_MAX} , min{ULONG_MAX}
{ {
} }
@ -51,10 +51,10 @@ public:
/* Everything below is in nanoseconds */ /* Everything below is in nanoseconds */
uint64_t start; uint64_t start;
uint64_t total; uint64_t total;
uint64_t least; uint64_t min;
uint64_t most; uint64_t max;
double mean; double avg;
double m2; double m2;
}; };