Search Unity

Little profiler understanding help please

Discussion in 'Editor & General Support' started by Shadowing, Jan 9, 2020.

  1. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Trying to learn more how the profiler works.

    Does this mean my scripts are taking up a ton of cpu? with it showing 30fps?
    All the other cpu options I click on the left show like 250 or some 1000 etc..

     
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    You've set the profiler to only show the cost of the scripts. The profiler shows that it takes ~33ms, spiking up to ~66ms to run your scripts.

    To run at 60fps, everything (including your scripts), has to take no more than 16ms, so you're for sure overspending.

    To figure out what's taking long, set your profiler to hierarchy mode (it defaults to Timeline, which imo is a bit useless unless you're debugging DOTS-stuff), click a frame, and sort by time (ms). That'll show which of your scripts are taking a long time.

    If you can't understand why those scripts are taking long, profile again in deep profiler mode, so you can see what those scripts are spending time on.
     
    Joe-Censored and Shadowing like this.
  3. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Oh thanks a bunch. I'll try that out. Ya that was my issue trying to figure out what is taking so long.
     
  4. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    I have a blank scene where I spawn 1,000 characters but I deactivated them after spawn.
    I'm getting like 1900 fps but I notice I get a huge spikes shown below for editorLoop.


     
  5. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    If you can, you should profile builds, as they give a more accurate representation of how your game will run. The editor has a good bit of overhaed.