mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 12:25:20 +03:00
Calculate moving sum delta time in 10ths us
This commit is contained in:
parent
4c034d67ee
commit
877adf4634
3 changed files with 7 additions and 7 deletions
|
@ -4924,7 +4924,7 @@ static void cliTasks(const char *cmdName, char *cmdline)
|
|||
taskInfo_t taskInfo;
|
||||
getTaskInfo(taskId, &taskInfo);
|
||||
if (taskInfo.isEnabled) {
|
||||
int taskFrequency = taskInfo.averageDeltaTimeUs == 0 ? 0 : lrintf(1e6f / taskInfo.averageDeltaTimeUs);
|
||||
int taskFrequency = taskInfo.averageDeltaTime10thUs == 0 ? 0 : lrintf(1e7f / taskInfo.averageDeltaTime10thUs);
|
||||
cliPrintf("%02d - (%15s) ", taskId, taskInfo.taskName);
|
||||
const int maxLoad = taskInfo.maxExecutionTimeUs == 0 ? 0 : (taskInfo.maxExecutionTimeUs * taskFrequency) / 1000;
|
||||
const int averageLoad = taskInfo.averageExecutionTimeUs == 0 ? 0 : (taskInfo.averageExecutionTimeUs * taskFrequency) / 1000;
|
||||
|
|
|
@ -211,7 +211,7 @@ void getTaskInfo(taskId_e taskId, taskInfo_t * taskInfo)
|
|||
taskInfo->maxExecutionTimeUs = getTask(taskId)->maxExecutionTimeUs;
|
||||
taskInfo->totalExecutionTimeUs = getTask(taskId)->totalExecutionTimeUs;
|
||||
taskInfo->averageExecutionTimeUs = getTask(taskId)->anticipatedExecutionTime >> TASK_EXEC_TIME_SHIFT;
|
||||
taskInfo->averageDeltaTimeUs = getTask(taskId)->movingSumDeltaTimeUs / TASK_STATS_MOVING_SUM_COUNT;
|
||||
taskInfo->averageDeltaTime10thUs = getTask(taskId)->movingSumDeltaTime10thUs / TASK_STATS_MOVING_SUM_COUNT;
|
||||
taskInfo->latestDeltaTimeUs = getTask(taskId)->taskLatestDeltaTimeUs;
|
||||
taskInfo->movingAverageCycleTimeUs = getTask(taskId)->movingAverageCycleTimeUs;
|
||||
#if defined(USE_LATE_TASK_STATISTICS)
|
||||
|
@ -291,12 +291,12 @@ void schedulerResetTaskStatistics(taskId_e taskId)
|
|||
{
|
||||
if (taskId == TASK_SELF) {
|
||||
currentTask->anticipatedExecutionTime = 0;
|
||||
currentTask->movingSumDeltaTimeUs = 0;
|
||||
currentTask->movingSumDeltaTime10thUs = 0;
|
||||
currentTask->totalExecutionTimeUs = 0;
|
||||
currentTask->maxExecutionTimeUs = 0;
|
||||
} else if (taskId < TASK_COUNT) {
|
||||
getTask(taskId)->anticipatedExecutionTime = 0;
|
||||
getTask(taskId)->movingSumDeltaTimeUs = 0;
|
||||
getTask(taskId)->movingSumDeltaTime10thUs = 0;
|
||||
getTask(taskId)->totalExecutionTimeUs = 0;
|
||||
getTask(taskId)->maxExecutionTimeUs = 0;
|
||||
}
|
||||
|
@ -388,7 +388,7 @@ FAST_CODE timeUs_t schedulerExecuteTask(task_t *selectedTask, timeUs_t currentTi
|
|||
if (!ignoreCurrentTaskExecRate) {
|
||||
// Record task execution rate and max execution time
|
||||
selectedTask->taskLatestDeltaTimeUs = cmpTimeUs(currentTimeUs, selectedTask->lastStatsAtUs);
|
||||
selectedTask->movingSumDeltaTimeUs += selectedTask->taskLatestDeltaTimeUs - selectedTask->movingSumDeltaTimeUs / TASK_STATS_MOVING_SUM_COUNT;
|
||||
selectedTask->movingSumDeltaTime10thUs += (selectedTask->taskLatestDeltaTimeUs * 10) - selectedTask->movingSumDeltaTime10thUs / TASK_STATS_MOVING_SUM_COUNT;
|
||||
selectedTask->lastStatsAtUs = currentTimeUs;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ typedef struct {
|
|||
timeUs_t maxExecutionTimeUs;
|
||||
timeUs_t totalExecutionTimeUs;
|
||||
timeUs_t averageExecutionTimeUs;
|
||||
timeUs_t averageDeltaTimeUs;
|
||||
timeUs_t averageDeltaTime10thUs;
|
||||
float movingAverageCycleTimeUs;
|
||||
#if defined(USE_LATE_TASK_STATISTICS)
|
||||
uint32_t runCount;
|
||||
|
@ -201,7 +201,7 @@ typedef struct {
|
|||
// Statistics
|
||||
float movingAverageCycleTimeUs;
|
||||
timeUs_t anticipatedExecutionTime; // Fixed point expectation of next execution time
|
||||
timeUs_t movingSumDeltaTimeUs; // moving sum over 32 samples
|
||||
timeUs_t movingSumDeltaTime10thUs; // moving sum over 64 samples
|
||||
timeUs_t maxExecutionTimeUs;
|
||||
timeUs_t totalExecutionTimeUs; // total time consumed by task since boot
|
||||
timeUs_t lastStatsAtUs; // time of last stats gathering for rate calculation
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue