public static Action GetMarkerEnclosedSnippetAction(object preExecutePayload, ProfilingSnippet snippet, ProfilingSnippetOptions options)
        {
            var snippetAction = snippet.GetSnippetAction(preExecutePayload, options);

            if (!snippet.isValidMarker)
            {
                // Generate marker:
                var markerName = snippet.GetValidMarkerName();
                return(() =>
                {
                    using (new PerformanceTracker(markerName))
                    {
                        snippetAction();
                    }
                });
            }

            return(snippetAction);
        }
示例#2
0
        static void BenchmarkSnippet(object preExecutePayload, ProfilingSnippet snippet, ProfilingSnippetOptions options)
        {
            var snippetAction = snippet.GetSnippetAction(preExecutePayload, options);

            #if UNITY_2020_1_OR_NEWER
            if (!snippet.ranOnce && options.warmup)
            {
                snippetAction(); // This execution pass should JIT the code first.
                EditorApplication.CallDelayed(() => {
                    var result = ProfilerHelpers.Benchmark(snippetAction, options.count);
                    LogBenchmark(snippet.label, result, options);
                }, 0);
            }
            else
            #endif
            {
                var result = ProfilerHelpers.Benchmark(snippetAction, options.count);
                LogBenchmark(snippet.label, result, options);
            }
        }
示例#3
0
        static void ProfileSnippet(object preExecutePayload, ProfilingSnippet snippet, ProfilingSnippetOptions options, bool deepProfile)
        {
            var s = snippet.GetSnippetAction(preExecutePayload, options);

            ProfilerHelpers.RecordWithProfileSample(snippet.sampleName, s, true, deepProfile, options.count);
        }