mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
OP-1365 - adds quick and dirty decays to max and min values
This commit is contained in:
parent
bdd9ac7c60
commit
adbcdecb41
@ -52,8 +52,8 @@ pios_counter_t PIOS_Instrumentation_CreateCounter(uint32_t id)
|
||||
if (!counter_handle) {
|
||||
pios_perf_counter_t *newcounter = &pios_instrumentation_perf_counters[++pios_instrumentation_last_used_counter];
|
||||
newcounter->id = id;
|
||||
newcounter->max = INT32_MIN;
|
||||
newcounter->min = INT32_MAX;
|
||||
newcounter->max = INT32_MIN + 1;
|
||||
newcounter->min = INT32_MAX - 1;
|
||||
counter_handle = (pios_counter_t)newcounter;
|
||||
}
|
||||
return counter_handle;
|
||||
|
@ -53,9 +53,11 @@ inline void PIOS_Instrumentation_updateCounter(pios_counter_t counter_handle, in
|
||||
vPortEnterCritical();
|
||||
pios_perf_counter_t *counter = (pios_perf_counter_t *)counter_handle;
|
||||
counter->value = newValue;
|
||||
counter->max--;
|
||||
if (counter->value > counter->max) {
|
||||
counter->max = counter->value;
|
||||
}
|
||||
counter->min++;
|
||||
if (counter->value < counter->min) {
|
||||
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;
|
||||
|
||||
counter->value = PIOS_DELAY_DiffuS(counter->lastUpdateTS);
|
||||
counter->max--;
|
||||
if (counter->value > counter->max) {
|
||||
counter->max = counter->value;
|
||||
}
|
||||
counter->min++;
|
||||
if (counter->value < counter->min) {
|
||||
counter->min = counter->value;
|
||||
}
|
||||
@ -110,9 +114,11 @@ inline void PIOS_Instrumentation_TrackPeriod(pios_counter_t counter_handle)
|
||||
vPortEnterCritical();
|
||||
uint32_t period = PIOS_DELAY_DiffuS(counter->lastUpdateTS);
|
||||
counter->value = (counter->value * 15 + period) / 16;
|
||||
counter->max--;
|
||||
if ((int32_t)period > counter->max) {
|
||||
counter->max = period;
|
||||
}
|
||||
counter->min++;
|
||||
if ((int32_t)period < counter->min) {
|
||||
counter->min = period;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user