Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

FrameTimingManager.GetLatestTimings not working

Discussion in 'Scripting' started by ikomhoog, Jun 23, 2020.

  1. ikomhoog

    ikomhoog

    Joined:
    Feb 23, 2014
    Posts:
    5
    I have this bit of code:
    FrameTiming[] frameTimings = new FrameTiming[10];
    FrameTimingManager.CaptureFrameTimings();
    Debug.Log(FrameTimingManager.GetLatestTimings(10, frameTimings));
    Debug.Log(frameTimings[0].cpuFrameTime + " : " + frameTimings[0].gpuFrameTime);

    but it keeps returning "0" and "0 : 0", should this work on windows?
     
  2. Nstdspace

    Nstdspace

    Joined:
    Feb 6, 2020
    Posts:
    26
    According to this thread, this seems to work only on XBox.
     
  3. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,078
    It seems to work on all the consoles I've tried it on (xbox/ps4/switch) but not on Windows. The editor already has a 'stats' button that you can use and the profiler is pretty decent for debugging CPU & GPU timings.
     
  4. ikomhoog

    ikomhoog

    Joined:
    Feb 23, 2014
    Posts:
    5
    Im working on a multiplayer game, and want to determine which player is most suited to be a "host", or do extra calculations.
    I want to do that by comparing desired fps vs actual fps, and then seeing if its a cpu or gpu bottleneck.
    if the gpu is the bottleneck i can use more cpu from that user.
    is there another way i can do this?
     
  5. Nstdspace

    Nstdspace

    Joined:
    Feb 6, 2020
    Posts:
    26
  6. ikomhoog

    ikomhoog

    Joined:
    Feb 23, 2014
    Posts:
    5
    I tried that, but due to WaitForTargetFPS, the cpu is still used and it constantly shows 100% cpu usage.
    This is the same when switching from 1000 FPS to 60 FPS using application.TargetFrameRate.
     
  7. Nstdspace

    Nstdspace

    Joined:
    Feb 6, 2020
    Posts:
    26