# Task Execution Time

**URL:** <https://www.wago.community/t/task-execution-time/699>\
**Category:** CODESYS\
**Tags:** pfc200\
**Created:** [November 28, 2023, 10:59pm UTC](https://www.wago.community/t/task-execution-time/699 "2023-11-28T22:59:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![WagoKurt](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/wagokurt/32/11_2.png) [@WagoKurt](https://www.wago.community/u/WagoKurt)\
**Post date:** [November 28, 2023, 10:59pm UTC](https://www.wago.community/t/task-execution-time/699/1 "2023-11-28T22:59:01Z")

</div>

Is it possible to programmatically read the task execution time?

 ![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/21c0391d40a2f923c65a9c3d7792da3bd6e33c31.png)

---

<div class="post-metadata">

**Author:** ![quenorha](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/quenorha/32/429_2.png) [@quenorha](https://www.wago.community/u/quenorha)\
**Post date:** [November 29, 2023, 6:26am UTC](https://www.wago.community/t/task-execution-time/699/2 "2023-11-29T06:26:25Z")

</div>

I guess you can use the CmpIECTask library.  
I’ve found some information here

> **[CODESYS Tutorial: Getting the Actual Cycle Time of a Current Task](https://medium.com/@sean.gongz/how-to-get-current-task-actual-cycle-time-in-codesys-267384bcd3b7)**
>
> Read this article in 中文

---

<div class="post-metadata">

**Author:** ![WagoKurt](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/wagokurt/32/11_2.png) [@WagoKurt](https://www.wago.community/u/WagoKurt)\
**Post date:** [November 29, 2023, 4:51pm UTC](https://www.wago.community/t/task-execution-time/699/3 "2023-11-29T16:51:53Z")

</div>

![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/1def931595086ae5165787843583c3bf52c10bd0.png)

PROGRAM Task\_Control2  
VAR  
Result: CmpIecTask.RTS\_IEC\_RESULT;  
hTask : CmpIecTask.RTS\_IEC\_HANDLE;  
pCurrentTaskInfo: POINTER TO Task\_Info2;  
CurrentTaskInfo: Task\_Info2;  
xReset: BOOL;  
END\_VAR

hTask := IecTaskGetCurrent(ADR(Result));  
pCurrentTaskInfo := IecTaskGetInfo3(hIecTask := hTask, pResult := ADR(Result));  
CurrentTaskInfo := pCurrentTaskInfo^;

IF xReset THEN  
xReset := FALSE;  
IF hTask \<\> 0 THEN  
Result := IecTaskResetStatistics(hIecTask := hTask);  
END\_IF  
END\_IF

CurrentTaskInfo.dwCycleTime; // This contains the task cycle time in micro seconds.
