# Using cycle counters in multithreaded function

**URL:** <https://forums.unrealengine.com/t/using-cycle-counters-in-multithreaded-function/438623>\
**Category:** Debugging, Optimization, & Profiling\
**Tags:** stats, profiling, multithreading, unreal-engine, UE4, CPP, question\
**Created:** [November 30, 2018, 5:01pm UTC](https://forums.unrealengine.com/t/using-cycle-counters-in-multithreaded-function/438623 "2018-11-30T17:01:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_13399bb2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_13399bb2](https://forums.unrealengine.com/u/anonymous_user_13399bb2)\
**Post date:** [November 30, 2018, 5:01pm UTC](https://forums.unrealengine.com/t/using-cycle-counters-in-multithreaded-function/438623/1 "2018-11-30T17:01:15Z")

</div>

Lets say I have a function:

```
void fun(){
    SCOPE_CYCLE_COUNTER(STAT_fun);
    ... Do something
}

```

But fun will be getting called by multiple threads at the same time. Stat will thus complain about multiple threads using same CYCLE\_STAT. What is the correct way to get separate CYCLE\_STATS for each thread? So later when I look at the stat file you’ll have multiple STAT\_fun recorded for each of the different threads?
