1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

OP-1365 - adds quick and dirty decays to max and min values

This commit is contained in:
Alessio Morale 2014-12-29 16:41:33 +01:00
parent bdd9ac7c60
commit adbcdecb41
2 changed files with 8 additions and 2 deletions

View File

@ -52,8 +52,8 @@ pios_counter_t PIOS_Instrumentation_CreateCounter(uint32_t id)
if (!counter_handle) { if (!counter_handle) {
pios_perf_counter_t *newcounter = &pios_instrumentation_perf_counters[++pios_instrumentation_last_used_counter]; pios_perf_counter_t *newcounter = &pios_instrumentation_perf_counters[++pios_instrumentation_last_used_counter];
newcounter->id = id; newcounter->id = id;
newcounter->max = INT32_MIN; newcounter->max = INT32_MIN + 1;
newcounter->min = INT32_MAX; newcounter->min = INT32_MAX - 1;
counter_handle = (pios_counter_t)newcounter; counter_handle = (pios_counter_t)newcounter;
} }
return counter_handle; return counter_handle;

View File

@ -53,9 +53,11 @@ inline void PIOS_Instrumentation_updateCounter(pios_counter_t counter_handle, in
vPortEnterCritical(); vPortEnterCritical();
pios_perf_counter_t *counter = (pios_perf_counter_t *)counter_handle; pios_perf_counter_t *counter = (pios_perf_counter_t *)counter_handle;
counter->value = newValue; counter->value = newValue;
counter->max--;
if (counter->value > counter->max) { if (counter->value > counter->max) {
counter->max = counter->value; counter->max = counter->value;
} }
counter->min++;
if (counter->value < counter->min) { if (counter->value < counter->min) {
counter->min = counter->value; counter->min = counter->value;
} }
@ -88,9 +90,11 @@ inline void PIOS_Instrumentation_TimeEnd(pios_counter_t counter_handle)
pios_perf_counter_t *counter = (pios_perf_counter_t *)counter_handle; pios_perf_counter_t *counter = (pios_perf_counter_t *)counter_handle;
counter->value = PIOS_DELAY_DiffuS(counter->lastUpdateTS); counter->value = PIOS_DELAY_DiffuS(counter->lastUpdateTS);
counter->max--;
if (counter->value > counter->max) { if (counter->value > counter->max) {
counter->max = counter->value; counter->max = counter->value;
} }
counter->min++;
if (counter->value < counter->min) { if (counter->value < counter->min) {
counter->min = counter->value; counter->min = counter->value;
} }
@ -110,9 +114,11 @@ inline void PIOS_Instrumentation_TrackPeriod(pios_counter_t counter_handle)
vPortEnterCritical(); vPortEnterCritical();
uint32_t period = PIOS_DELAY_DiffuS(counter->lastUpdateTS); uint32_t period = PIOS_DELAY_DiffuS(counter->lastUpdateTS);
counter->value = (counter->value * 15 + period) / 16; counter->value = (counter->value * 15 + period) / 16;
counter->max--;
if ((int32_t)period > counter->max) { if ((int32_t)period > counter->max) {
counter->max = period; counter->max = period;
} }
counter->min++;
if ((int32_t)period < counter->min) { if ((int32_t)period < counter->min) {
counter->min = period; counter->min = period;
} }