# Using vTaskGetRunTimeStats( char \*pcWriteBuffer );

**URL:** <https://forums.freertos.org/t/using-vtaskgetruntimestats-char-pcwritebuffer/7171>\
**Category:** Kernel\
**Created:** [April 28, 2018, 7:05pm UTC](https://forums.freertos.org/t/using-vtaskgetruntimestats-char-pcwritebuffer/7171 "2018-04-28T19:05:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 28, 2018, 7:05pm UTC](https://forums.freertos.org/t/using-vtaskgetruntimestats-char-pcwritebuffer/7171/1 "2018-04-28T19:05:46Z")

</div>

**[ose](https://sourceforge.net/u/ose/)** wrote on [Saturday, April 28, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/8d6d3a1b/#7f6c):

Hallo,  
I am trying to use the vTaskGetRunTimeStats to display the task execution time in a tabular form.  
First of all, should i call the function in the main function, like after the vTaskStartScheduler?

Secondly, what then do I have to do to see the tabular format ? Because from [https://www.freertos.org/rtos-run-time-stats.html](https://www.freertos.org/rtos-run-time-stats.html) , it looks like on the example picture one has to put in an ip addresss or so.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [April 29, 2018, 6:29pm UTC](https://forums.freertos.org/t/using-vtaskgetruntimestats-char-pcwritebuffer/7171/2 "2018-04-29T18:29:25Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Sunday, April 29, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/8d6d3a1b/#4716):

I replied to this via email but the post didn’t show - apologies if it now shows up twice:

> First of all, should i call the function in the main function, like after the vTaskStartScheduler?

No - nothing that appears vTaskStartScheduler() will ever be reached s(assuming vTaskStartScheduler() actually starts the scheduler - which will be the case unless you run out of heap when creating the idle and/or timer tasks) so it won’t execute if you put it there.

It should be called from whichever task you want to print the stats.

> Secondly, what then do I have to do to see the tabular format ? Because from [FreeRTOS Run Time Stats](https://www.freertos.org/rtos-run-time-stats.html) , it looks like on the example picture one has to put in an ip addresss or so.

The page you link to shows how to use run-time stats in general, including how to set up the clocks. The API page for vTaskGetRunTimeStats() is here [RTOS task (thread) utilities including API functions for tracing FreeRTOS, getting the RTOS tick count, getting a task handle, getting the RTOS kernel or RTOS scheduler state, listing the tasks in the embedded system, and obtaining run time task statistics.](https://www.freertos.org/a00021.html#vTaskGetRunTimeStats) and shows you pass in the address of the buffer into which you would like the stats to be written. That pages also shows the prerequisites of having configGENERATE\_RUN\_TIME\_STATS and configUSE\_STATS\_FORMATTING\_FUNCTIONS defined.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [April 29, 2018, 8:12pm UTC](https://forums.freertos.org/t/using-vtaskgetruntimestats-char-pcwritebuffer/7171/3 "2018-04-29T20:12:15Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Sunday, April 29, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/8d6d3a1b/#7f6c/5a91):

> First of all, should i call the function in the main function, like  
> after the vTaskStartScheduler?

No - nothing that appears vTaskStartScheduler() will ever be reached  
s(assuming vTaskStartScheduler() actually starts the scheduler - which  
will be the case unless you run out of heap when creating the idle  
and/or timer tasks) so it won’t execute if you put it there.

It should be called from whichever task you want to print the stats.

> Secondly, what then do I have to do to see the tabular format ? Because  
> from [FreeRTOS Run Time Stats](https://www.freertos.org/rtos-run-time-stats.html) , it looks like  
> on the example picture one has to put in an ip addresss or so.

The page you link to shows how to use run-time stats in general,  
including how to set up the clocks. The API page for  
vTaskGetRunTimeStats() is here  
[RTOS task (thread) utilities including API functions for tracing FreeRTOS, getting the RTOS tick count, getting a task handle, getting the RTOS kernel or RTOS scheduler state, listing the tasks in the embedded system, and obtaining run time task statistics.](https://www.freertos.org/a00021.html#vTaskGetRunTimeStats) and shows you  
pass in the address of the buffer into which you would like the stats to  
be written. That pages also shows the prerequisites of having  
configGENERATE\_RUN\_TIME\_STATS and configUSE\_STATS\_FORMATTING\_FUNCTIONS  
defined.

---

<div class="post-metadata">

**Author:** ![tlafleur](https://avatars.discourse-cdn.com/v4/letter/t/a6a055/32.png) [@tlafleur](https://forums.freertos.org/u/tlafleur)\
**Post date:** [April 29, 2018, 8:45pm UTC](https://forums.freertos.org/t/using-vtaskgetruntimestats-char-pcwritebuffer/7171/4 "2018-04-29T20:45:26Z")

</div>

**[tlafleur](https://sourceforge.net/u/tlafleur/)** wrote on [Sunday, April 29, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/8d6d3a1b/#4716/9327):

Richard…

as it relates to this, have the stats show what CPU core is attach to what  
task would be good addition in multi core CPU…

thanks

~~\_/) `_/)` \_/) ``` \_/)~~

Tom Lafleur

On Sun, Apr 29, 2018 at 11:29 AM, Richard Barry [rtel@users.sourceforge.net](mailto:rtel@users.sourceforge.net)  
wrote:

> I replied to this via email but the post didn’t show - apologies if it now  
> shows up twice:
> 
> First of all, should i call the function in the main function, like after  
> the vTaskStartScheduler?
> 
> No - nothing that appears vTaskStartScheduler() will ever be reached  
> s(assuming vTaskStartScheduler() actually starts the scheduler - which will  
> be the case unless you run out of heap when creating the idle and/or timer  
> tasks) so it won’t execute if you put it there.
> 
> It should be called from whichever task you want to print the stats.
> 
> Secondly, what then do I have to do to see the tabular format ? Because  
> from [FreeRTOS Run Time Stats](https://www.freertos.org/rtos-run-time-stats.html) , it looks like on  
> the example picture one has to put in an ip addresss or so.
> 
> ## The page you link to shows how to use run-time stats in general, including how to set up the clocks. The API page for vTaskGetRunTimeStats() is here [RTOS task (thread) utilities including API functions for tracing FreeRTOS, getting the RTOS tick count, getting a task handle, getting the RTOS kernel or RTOS scheduler state, listing the tasks in the embedded system, and obtaining run time task statistics.](https://www.freertos.org/a00021.html#vTaskGetRunTimeStats) and shows you pass in the address of the buffer into which you would like the stats to be written. That pages also shows the prerequisites of having configGENERATE\_RUN\_TIME\_STATS and configUSE\_STATS\_FORMATTING\_FUNCTIONS defined.
> 
> ## Using vTaskGetRunTimeStats( char \*pcWriteBuffer ); [https://sourceforge.net/p/freertos/discussion/382005/thread/8d6d3a1b/?limit=25#4716](https://sourceforge.net/p/freertos/discussion/382005/thread/8d6d3a1b/?limit=25#4716)
> 
> Sent from [sourceforge.net](http://sourceforge.net) because you indicated interest in  
> [SourceForge.net: Log In to SourceForge.net](https://sourceforge.net/p/freertos/discussion/382005/)
> 
> To unsubscribe from further messages, please visit  
> [SourceForge.net: Log In to SourceForge.net](https://sourceforge.net/auth/subscriptions/)
