Finding Task Creation time in FreeRTOS

Hi, I want to measure some parameters such as Boot Time, Task Creation Time, Mutex Lock Time, in order to do a performance analysis. How could I go about doing it?. xTaskGetTickCount() doesn’t seem to work as it only returns the ticks after the scheduler has started the tasks.

First is to understand how to configure the system for throughput. For example, the thing that takes the longest in a context switch is checking for a stack overflow - but that is actually nothing to do with the context switch. See https://freertos.org/FAQMem.html#ContextSwitchTime for hints on configuration. Next is to decide what it is you are measuring. For example, are you measuring the number of instructions to perform an operation, or the speed at which you are clocking the MCU? If the former then the easiest way is to use a simulator that allows you to see the number of clock cycles. If the later then you can use an oscilloscope with digital IO marking times, or a fast clock on the MCU. You can also use a trace tool - but by doing so you are also measuring the time taken to make the trace recordings.

[edit] Should also say to understand the nuances of the system. For example: https://freertos.org/2020/09/decrease-ram-footprint-and-accelerate-execution-with-freertos-notifications.html [/edit]

1 Like

It depends a LOT on the CPU and the resources you have available, and how long of a span you might need.
Many processors have hardware timers that you can read and the differences will give you the elapsed time in some defined unit (at least until the counter wraps).

1 Like

Are you aware of our Tracealyzer tool? It allows ypu to add “user events” in the code and measure the time in between (using “custom intervals”).

1 Like

Where can I get it from? I’m currently using the SPIKE simulator for simulating a RISC-V processor.

See https://percepio.com/tz/freertostrace.

1 Like