From fb18eeb96cdc602a4d0fdfa2fd2ba9ad6278466c Mon Sep 17 00:00:00 2001 From: Richard Barry Date: Thu, 13 Jan 2011 19:04:57 +0000 Subject: [PATCH] Make the generation of run time stats percentages more efficient. --- Source/tasks.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Source/tasks.c b/Source/tasks.c index ab4bc9f38..a436a86eb 100644 --- a/Source/tasks.c +++ b/Source/tasks.c @@ -1295,6 +1295,10 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void ) ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE(); #endif + /* Divide ulTotalRunTime by 100 to make the percentage caluclations + simpler in the prvGenerateRunTimeStatsForTasksInList() function. */ + ulTotalRunTime /= 100UL; + /* Run through all the lists that could potentially contain a TCB, generating a table of run timer percentages in the provided buffer. */ @@ -2125,9 +2129,10 @@ tskTCB *pxNewTCB; } else { - /* What percentage of the total run time as the task used? - This will always be rounded down to the nearest integer. */ - ulStatsAsPercentage = ( 100UL * pxNextTCB->ulRunTimeCounter ) / ulTotalRunTime; + /* What percentage of the total run time has the task used? + This will always be rounded down to the nearest integer. + ulTotalRunTime has already been divided by 100. */ + ulStatsAsPercentage = pxNextTCB->ulRunTimeCounter / ulTotalRunTime; if( ulStatsAsPercentage > 0UL ) {