Пример #1
0
 static int GetNonEditorOnlyMarkerNameAndId(FrameDataView frameDataView, ref string name, int markerId)
 {
     if (name.StartsWith(k_EditorOnlyPrefix))
     {
         name = name.Substring(k_EditorOnlyPrefix.Length, name.Length - (k_EditorOnlyPrefix.Length + 1)); // + for the closing ]
         return(frameDataView.GetMarkerId(name));
     }
     return(markerId);
 }
    static float ExtractAdaptivePerformanceCounterValueFloat(UnityEditor.Profiling.FrameDataView frameData, string counterName)
    {
        if (frameData == null || counterName.Length == 0)
        {
            return(0);
        }

        var counterMarkerId = frameData.GetMarkerId(counterName);

        return(frameData.GetCounterValueAsFloat(counterMarkerId));
    }
Пример #3
0
        // NOTE: Only pass legacyMarkerNamePath if you already got it anyways (e.g. through Native Timeline selection API), otherwise leave it null, it will be generated here.
        internal void GenerateMarkerNamePath(FrameDataView frameDataView, List <int> markerIdPath, string legacyMarkerNamePath = null)
        {
            if (markerIdPath == null || markerIdPath.Count <= 0)
            {
                throw new ArgumentException($"{nameof(markerIdPath)} can't be null or empty", nameof(markerIdPath));
            }
            m_MarkerIdPath = markerIdPath;
            if (legacyMarkerNamePath == null)
            {
                // TODO: replace with MutableString once available
                var propertyPathBuilder = new StringBuilder();
                markerPathDepth  = markerIdPath.Count;
                m_MarkerNamePath = new List <string>(markerPathDepth);
                for (int i = 0; i < markerPathDepth - 1; i++)
                {
                    var name = frameDataView.GetMarkerName(markerIdPath[i]);
                    if (IsEditorOnlyMarker(frameDataView, markerIdPath[i]))
                    {
                        // if this was an Editor Only sample, get the proper id and name
                        markerIdPath[i] = GetNonEditorOnlyMarkerNameAndId(frameDataView, ref name, markerIdPath[i]);
                    }
                    propertyPathBuilder.Append(name);
                    propertyPathBuilder.Append('/');
                    m_MarkerNamePath.Add(name);
                }
                var lastMarkerId = markerIdPath[markerPathDepth - 1];
                // note: not necessarily the same as this.sampleName because that could be a deep profiling scripting marker name with the assembly name stripped
                var lastSampleName = frameDataView.GetMarkerName(lastMarkerId);

                if (IsEditorOnlyMarker(frameDataView, lastMarkerId))
                {
                    // if this was an Editor Only sample, get the proper id and name
                    markerIdPath[markerPathDepth - 1] = GetNonEditorOnlyMarkerNameAndId(frameDataView, ref lastSampleName, lastMarkerId);
                    // if it isn't a Deep Profiling sample, update this.sampleName too
                    if ((frameDataView.GetMarkerFlags(markerIdPath[markerPathDepth - 1]) & MarkerFlags.ScriptDeepProfiler) == 0)
                    {
                        sampleDisplayName = lastSampleName;
                    }
                }
                propertyPathBuilder.Append(lastSampleName);
                m_MarkerNamePath.Add(lastSampleName);
                this.legacyMarkerPath = propertyPathBuilder.ToString();
            }
            else
            {
                // TODO: replace with MutableString once available
                markerPathDepth  = markerIdPath.Count;
                m_MarkerNamePath = new List <string>(markerPathDepth);
                for (int i = 0; i < markerPathDepth - 1; i++)
                {
                    var name = frameDataView.GetMarkerName(markerIdPath[i]);
                    if (IsEditorOnlyMarker(frameDataView, markerIdPath[i]))
                    {
                        // if this was an Editor Only sample, get the proper id and name
                        markerIdPath[i] = GetNonEditorOnlyMarkerNameAndId(frameDataView, ref name, markerIdPath[i]);
                    }
                    m_MarkerNamePath.Add(name);
                }
                var lastMarkerId = markerIdPath[markerPathDepth - 1];
                // note: not necessarily the same as this.sampleName because that could be a deep profiling scripting marker name with the assembly name stripped
                var lastSampleName = frameDataView.GetMarkerName(markerIdPath[markerPathDepth - 1]);

                if (IsEditorOnlyMarker(frameDataView, lastMarkerId))
                {
                    // if this was an Editor Only sample, get the proper id and name
                    markerIdPath[markerPathDepth - 1] = GetNonEditorOnlyMarkerNameAndId(frameDataView, ref lastSampleName, lastMarkerId);
                    // if it isn't a Deep Profiling sample, update this.sampleName too
                    if ((int)(frameDataView.GetMarkerFlags(markerIdPath[markerPathDepth - 1]) & MarkerFlags.ScriptDeepProfiler) == 0)
                    {
                        sampleDisplayName = lastSampleName;
                    }
                }
                m_MarkerNamePath.Add(lastSampleName);
                this.legacyMarkerPath = legacyMarkerNamePath;
            }
        }
Пример #4
0
 static bool IsEditorOnlyMarker(FrameDataView frameDataView, int markerId)
 {
     return(markerId < 0 && (int)(frameDataView.GetMarkerFlags(markerId) & MarkerFlags.AvailabilityEditor) != 1);
 }
Пример #5
0
 // NOTE: Only pass legacyMarkerNamePath if you already got it anyways (e.g. through Native Timeline selection API), otherwise leave it null, it will be generated here.
 internal void GenerateMarkerNamePath(FrameDataView frameDataView, string sampleName, List <int> markerIdPath, string legacyMarkerNamePath = null)
 {
     this.sampleDisplayName = sampleName;
     GenerateMarkerNamePath(frameDataView, markerIdPath, legacyMarkerNamePath);
 }