]> git.sur5r.net Git - freertos/commitdiff
Make the generation of run time stats percentages more efficient.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 13 Jan 2011 19:04:57 +0000 (19:04 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 13 Jan 2011 19:04:57 +0000 (19:04 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1247 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Source/tasks.c

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