# vApplicationTickHook()

**URL:** <https://forums.freertos.org/t/vapplicationtickhook/6960>\
**Category:** Kernel\
**Created:** [February 4, 2018, 10:51am UTC](https://forums.freertos.org/t/vapplicationtickhook/6960 "2018-02-04T10:51:13Z")\
**Posts on this page:** 2\
**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:** [February 4, 2018, 10:51am UTC](https://forums.freertos.org/t/vapplicationtickhook/6960/1 "2018-02-04T10:51:13Z")

</div>

**[davidmillarpowe](https://sourceforge.net/u/davidmillarpowe/)** wrote on [Sunday, February 04, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/25d43d93/#7c9a):

Does anyone have information on the use of vApplicationTickHook() to measure the execution time of a task?  
Thanks.

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [February 4, 2018, 2:28pm UTC](https://forums.freertos.org/t/vapplicationtickhook/6960/2 "2018-02-04T14:28:19Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Sunday, February 04, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/25d43d93/#fd7f):

Yes, `vApplicationTickHook()` can be used to measure execution times of task, but I would not recommend it. The hook is running from an ISR.

In a way, `xTaskGetTickCount()` can also be useful to measure clock ticks.

What I like to use is this:

```auto
#if ( configUSE_TRACE_FACILITY == 1 )

	UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime );

#endif

```

It uses some MACRO’s that must be defined by you:

```auto
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()	vStartRunTimeCounter()
#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue()

```

Please check-out [freertos.org](https://www.freertos.org/rtos-run-time-stats.html) to find the details.

You can use a high-resolution TC (timer/counter) to measure the time. This allows you to get statistics in units of micro-seconds.
