# Measure Time within a Task with xTaskGetTickCount()

**URL:** <https://forums.freertos.org/t/measure-time-within-a-task-with-xtaskgettickcount/7402>\
**Category:** Kernel\
**Created:** [September 1, 2018, 4:26pm UTC](https://forums.freertos.org/t/measure-time-within-a-task-with-xtaskgettickcount/7402 "2018-09-01T16:26:49Z")\
**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:** [September 1, 2018, 4:26pm UTC](https://forums.freertos.org/t/measure-time-within-a-task-with-xtaskgettickcount/7402/1 "2018-09-01T16:26:49Z")

</div>

**[gibsonpw](https://sourceforge.net/u/gibsonpw/)** wrote on [Saturday, September 01, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/031a68b7/#815a):

Hi,

I am trying to measure the execution time of a function a FreeRTOS task with xTaskGetTickCount(). The code looks like the following example.

```auto
static void prvRxTask( void *pvParameters )
{

	for( ;; )
	{
		long start = xTaskGetTickCount();
        func_doing_something();
        long stop = xTaskGetTickCount() - start;
        
		vTaskDelay( pdMS_TO_TICKS( 1000UL ) );

	}
}

```

My result of stop is always “0” because the xTaskGetTickCount() gets not incremented durring the tasks execution. Why is that so? (I activated the timer in the FreeRTOSConfig.h) If it is relevant, I am using a Zedboard with a Zynq 7000 SoC.

---

<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:** [September 2, 2018, 3:18am UTC](https://forums.freertos.org/t/measure-time-within-a-task-with-xtaskgettickcount/7402/2 "2018-09-02T03:18:20Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Sunday, September 02, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/031a68b7/#4dce):

Duplicate of [https://sourceforge.net/p/freertos/discussion/382005/thread/6d2307a0/](https://sourceforge.net/p/freertos/discussion/382005/thread/6d2307a0/)
