Make the generation of run time stats percentages more efficient.

This commit is contained in:
Richard Barry 2011-01-13 19:04:57 +00:00
parent 411364dab6
commit fb18eeb96c

View File

@ -1295,6 +1295,10 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE(); ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE();
#endif #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, /* Run through all the lists that could potentially contain a TCB,
generating a table of run timer percentages in the provided generating a table of run timer percentages in the provided
buffer. */ buffer. */
@ -2125,9 +2129,10 @@ tskTCB *pxNewTCB;
} }
else else
{ {
/* What percentage of the total run time as the task used? /* What percentage of the total run time has the task used?
This will always be rounded down to the nearest integer. */ This will always be rounded down to the nearest integer.
ulStatsAsPercentage = ( 100UL * pxNextTCB->ulRunTimeCounter ) / ulTotalRunTime; ulTotalRunTime has already been divided by 100. */
ulStatsAsPercentage = pxNextTCB->ulRunTimeCounter / ulTotalRunTime;
if( ulStatsAsPercentage > 0UL ) if( ulStatsAsPercentage > 0UL )
{ {