public static void OnFrame() { if (!Enabled) return; Profiler.End("frame"); #if PLATFORM_MONOMAC || PLATFORM_MONOTOUCH || PLATFORM_MONODROID if (ProfileGPU) { // this stalls and waits for the gpu to finish PlayScript.Profiler.Begin("gpu", ".rend.gl.swap"); GL.Finish(); PlayScript.Profiler.End("gpu"); } #endif // update all sections foreach (Section section in sSectionList) { section.TotalTime += section.Timer.Elapsed; if (sDoReport) { // pad with zeros if necessary while (section.History.Count < sFrameCount) { section.History.Add(new SectionHistory()); } var history = new SectionHistory(); history.Time = section.Timer.Elapsed; history.GCCount = section.GCCount; section.History.Add(history); } section.GCCount = 0; section.Timer.Reset(); } sFrameCount++; if (!sDoReport) { // normal profiling, just print out every so often if ((sPrintFrameCount!=0) && (sFrameCount >= sPrintFrameCount)) { PrintTimes(System.Console.Out); Reset(); } } else { // report generation, accumulate a specified number of frames and then print report if (sFrameCount >= sReportFrameCount) { // print out report OnEndReport(); Reset(); sDoReport = false; } } // check start report countdown if (sReportStartDelay > 0) { if (--sReportStartDelay == 0) { OnStartReport(); } } Profiler.Begin("frame"); }
// this should be called at the end of a frame public static void OnEndFrame() { if (!Enabled) { return; } if (EmitSlowFrames && LastTelemetryFrameSpanStart != long.MaxValue) { long endFrameTime = Stopwatch.GetTimestamp(); long spanTimeInTicks = endFrameTime - LastTelemetryFrameSpanStart; // From ticks to ns double spanTimeInNs = (double)spanTimeInTicks * (1000000000.0 / (double)Stopwatch.Frequency); PerformanceFrameData frameData = GetPerformanceFrameData(); double autoProfileFrameInNs = frameData.AutoProfileFrame * 1000000.0; // Convert ms to ns if (spanTimeInNs >= autoProfileFrameInNs) { Telemetry.Session.EndSpan("SlowFrame", LastTelemetryFrameSpanStart); } } Profiler.End("frame"); #if PLATFORM_MONOMAC || PLATFORM_MONOTOUCH || PLATFORM_MONODROID if (ProfileGPU) { // this stalls and waits for the gpu to finish PlayScript.Profiler.Begin("gpu", ".rend.gl.swap"); GL.Finish(); PlayScript.Profiler.End("gpu"); } #endif sFrameCount += NextFramesElapsed; MaxNumberOfFramesElapsed = Math.Max(MaxNumberOfFramesElapsed, NextFramesElapsed); // update all sections foreach (Section section in sSectionList) { section.TotalTime += section.Timer.Elapsed; if (sDoReport) { // pad with zeros if necessary while (section.History.Count < sFrameCount) { section.History.Add(ZeroSectionHistory); } var history = new SectionHistory(); history.Time = section.Timer.Elapsed; history.NumberOfCalls = section.NumberOfCalls; #if ENABLE_GC_COUNTS for (int i = sGCMinGeneration; i < Profiler.sGCMaxGeneration; ++i) { history.GCCounts[i] = section.GCCounts[i]; } #endif section.History.Add(history); } #if ENABLE_GC_COUNTS for (int i = sGCMinGeneration; i < Profiler.sGCMaxGeneration; ++i) { section.GCCounts[i] = 0; } #endif section.Timer.Reset(); section.NumberOfCalls = 0; } if (!sDoReport) { // normal profiling, just print out every so often if ((sPrintFrameCount != 0) && (sFrameCount >= sPrintFrameCount)) { PrintTimes(System.Console.Out); Reset(); } } else { // report generation, accumulate a specified number of frames and then print report if (sFrameCount >= sReportFrameCount) { // print out report OnEndReport(); Reset(); sDoReport = false; } } // check start report countdown if (sReportStartDelay > 0) { if (--sReportStartDelay == 0) { OnStartReport(); } } }
public static void OnFrame() { if (!Enabled) { return; } // update all sections foreach (Section section in sSections.Values) { section.TotalTime += section.Timer.Elapsed; if (sDoReport) { // pad with zeros if necessary while (section.History.Count < sFrameCount) { section.History.Add(new SectionHistory()); } var history = new SectionHistory(); history.Time = section.Timer.Elapsed; history.GCCount = section.GCCount; section.History.Add(history); } section.GCCount = 0; section.Timer.Reset(); } sFrameCount++; if (!sDoReport) { // normal profiling, just print out every so often if ((sPrintFrameCount != 0) && (sFrameCount >= sPrintFrameCount)) { PrintTimes(System.Console.Out); Reset(); } } else { // report generation, accumulate a specified number of frames and then print report if (sFrameCount >= sReportFrameCount) { // print out report DoReport(); Reset(); sDoReport = false; } } // check start report countdown if (sReportStartDelay > 0) { if (--sReportStartDelay == 0) { System.GC.Collect(); // reset counters Reset(); // enable the report sDoReport = true; sReportGCCount = System.GC.CollectionCount(System.GC.MaxGeneration); // start global timer sReportTime = Stopwatch.StartNew(); } } }
public static void OnFrame() { if (!Enabled) return; Profiler.End("frame"); // update all sections foreach (Section section in sSectionList) { section.TotalTime += section.Timer.Elapsed; if (sDoReport) { // pad with zeros if necessary while (section.History.Count < sFrameCount) { section.History.Add(new SectionHistory()); } var history = new SectionHistory(); history.Time = section.Timer.Elapsed; history.GCCount = section.GCCount; section.History.Add(history); } section.GCCount = 0; section.Timer.Reset(); } sFrameCount++; if (!sDoReport) { // normal profiling, just print out every so often if ((sPrintFrameCount!=0) && (sFrameCount >= sPrintFrameCount)) { PrintTimes(System.Console.Out); Reset(); } } else { // report generation, accumulate a specified number of frames and then print report if (sFrameCount >= sReportFrameCount) { // print out report OnEndReport(); Reset(); sDoReport = false; } } // check start report countdown if (sReportStartDelay > 0) { if (--sReportStartDelay == 0) { OnStartReport(); } } Profiler.Begin("frame"); }
public static void OnFrame() { if (!Enabled) { return; } Profiler.End("frame"); #if PLATFORM_MONOMAC || PLATFORM_MONOTOUCH || PLATFORM_MONODROID if (ProfileGPU) { // this stalls and waits for the gpu to finish PlayScript.Profiler.Begin("gpu", ".rend.gl.swap"); GL.Finish(); PlayScript.Profiler.End("gpu"); } #endif // update all sections foreach (Section section in sSectionList) { section.TotalTime += section.Timer.Elapsed; if (sDoReport) { // pad with zeros if necessary while (section.History.Count < sFrameCount) { section.History.Add(new SectionHistory()); } var history = new SectionHistory(); history.Time = section.Timer.Elapsed; history.GCCount = section.GCCount; section.History.Add(history); } section.GCCount = 0; section.Timer.Reset(); } sFrameCount++; if (!sDoReport) { // normal profiling, just print out every so often if ((sPrintFrameCount != 0) && (sFrameCount >= sPrintFrameCount)) { PrintTimes(System.Console.Out); Reset(); } } else { // report generation, accumulate a specified number of frames and then print report if (sFrameCount >= sReportFrameCount) { // print out report OnEndReport(); Reset(); sDoReport = false; } } // check start report countdown if (sReportStartDelay > 0) { if (--sReportStartDelay == 0) { OnStartReport(); } } Profiler.Begin("frame"); }