Convert Unity CPU Clock Time to milliseconds

Hi i’m trying to implement custom runtime profiling tool to my project.
image

I’m looking into FrameTimingManager and found
cpuTimePresentCalled
cpuTimeFrameComplete
firstSubmitTimestamp
cpuTimeFrameComplete

image
these value time are cpu clock time and i’m trying to convert them to
milliseconds.

found some article about FrameTimingManager.GetCPUTimerFrequency() but couldn’t figure the way to convert it to milliseconds.

I’ve checked and the cpu timestamp metrics are in ticks, so you do need to convert those into seconds or milliseconds manually

I believe using something like

cpuTimePresentCalledMilliSeconds = (cpuTimePresentCalled * 1000.0) / FrameTimingManager.GetCPUTimerFrequency()

cpuTimePresentCalledSeconds = (cpuTimePresentCalled * 1.0) / FrameTimingManager.GetCPUTimerFrequency()

would do the work

You can achieve cleaner ticks conversion if you employ TimeSpan.

For example

var interval = new TimeSpan(ticks);
Debug.Log($"{interval.Milliseconds} ms");

or

Debug.Log($"{ticks * TimeSpan.TicksPerMillisecond} ms");

No magic numbers involved.