Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Search for samples by name in the profiler

Discussion in 'Profiler Previews' started by jdtec, Jan 27, 2021.

  1. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    302
    eg. if I want to step through each 'JobSystem:SampleJobToProfile' in the profiler across frames, how do I do this?

    A ctrl-f and entering a profile marker name to highlight the matching blocks in the timeline view would accomplish what I want.
     
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,451
    Hi there,

    Thank you for your feedback. Having better search and filtering options, specifically for Timeline, is already in our feature request backlog. Meanwhile the best workaround for this being missing that I can offer is a script like this one. It only works from 2020.1 up and only gets really useful from 2021.1 on (where you can actually drive the selection in the Profiler Window from API, so the script can select the first sample you where searching for for you in the CPU Profiler Module) but I hope that helps until search and filtering improvements get tackled by us.
     

    Attached Files:

  3. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,451
    For earlier Unity versions, Profile Analyzer can also help you to search across all frames and threads to find your samples.
     
  4. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,451
    If you're on 2019.4 you could also adapt it to use HierarchyFrameDataView, which is going to be a bit slower but at least functional. Keep in mind that it's supported (albeit broken for 2020.1 and no longer possible to fix) to use a newer Editor to profile an App build from an older Unity version.
     
  5. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    302
    Thanks @MartinTilo that's very helpful and glad to hear there are features planned for this. I will try your script out.

    In the meantime I did this for my issue yesterday and displayed the data using imgui, which worked well, obviously you don't want to have to rely on this for everything but nice for specialist things you want to keep an eye on.

    Code (CSharp):
    1. Sampler sample = Sampler.Get ("BuildIntegrationField");
    2.  
    3.     public static bool GetPrevFrameSampleTotal (Sampler sampler, out float totalMilliseconds)
    4.     {
    5.       Recorder recorder = sampler.GetRecorder ();
    6.       if (recorder.sampleBlockCount == 0)
    7.       {
    8.         totalMilliseconds = 0.0f;
    9.         return false;
    10.       }
    11.  
    12.       totalMilliseconds = ((float)recorder.elapsedNanoseconds * 0.000001f);
    13.       return true;
    14.     }
     
    MartinTilo likes this.
  6. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,451
    Yeap that can help too, and the new 2020.2 api ProfilerRecorder allows you to go even more into detail like getting individual sample times within a frame and keeping recording results for multiple samples.
     
    jdtec likes this.