获取转换比率,从 Profiler 时间戳到纳秒。
用于转换使用 GetTimestamp 获取的 Profiler 时间戳值到纳秒。
using Unity.Profiling.LowLevel.Unsafe;
public class Example { public static long ElapsedNanoseconds(long startTimestamp) { long now = ProfilerUnsafeUtility.Timestamp; var conversionRatio = ProfilerUnsafeUtility.TimestampToNanosecondsConversionRatio; return (now - startTimestamp) * conversionRatio.Numerator / conversionRatio.Denominator; } }