# Profile sub functions

**URL:** https://discussions.unity.com/t/profile-sub-functions/660351
**Category:** Scripting
**Tags:** Scripting
**Created:** [April 3, 2017, 12:09pm UTC](https://discussions.unity.com/t/profile-sub-functions/660351 "2017-04-03T12:09:38Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![HWDKoblenz](https://avatars.discourse-cdn.com/v4/letter/h/ccd318/32.png) [@HWDKoblenz](https://discussions.unity.com/u/HWDKoblenz)
#### Post date: [April 3, 2017, 12:09pm UTC](https://discussions.unity.com/t/profile-sub-functions/660351/1 "2017-04-03T12:09:38Z")

</div>

Hi everyone. I have a little question about profiling. As long I’m make some Profiler inside void Start() everything is fine like:

void Start()  
{  
Profiler.BeginSample(“TEST”);  
myFunction();  
Profiler.EndSample();  
}

After this I can see a single Sample in the profiler - perfect. But now imagine that “myfunction” has 2 or more sub functions. Then I see the complete hierarchies of all samples. But I want to collapse all the same Samples into one, so I know which sub functions are ineffective. I’m not interested in every single function call. How does this work?

```csharp
void Start()
{
     Profiler.BeginSample("TESTALL");
     myFunction();
     Profiler.EndSample();
}

//this is not correct !!!!
void myFunction(){
     // want to collapse TESTFIRST into one Profilerblock

     Profiler.BeginSample("TESTFIRST");
     myFunctionInsideOne();
     Profiler.EndSample();

     // want to collapse TESTSECOND into one Profilerblock

     Profiler.BeginSample("TESTSECOND");
     myFunctionInsideTwo();
     Profiler.EndSample();

}

```

Thanks =)  
Chris

---

<div class="post-metadata">

### Author: ![Baste](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/baste/32/880289_2.png) [@Baste](https://discussions.unity.com/u/Baste)
#### Post date: [April 3, 2017, 2:45pm UTC](https://discussions.unity.com/t/profile-sub-functions/660351/2 "2017-04-03T14:45:52Z")

</div>

[Please use code tags](https://forum.unity3d.com/threads/using-code-tags-properly.143875/).
