Ejemplo n.º 1
0
        public static CPUElement Create(UnityEditorInternal.ProfilerProperty root)
        {
            allCPUEle = new List <CPUElement>();
            if (allCPUEle == null)
            {
                return(null);
            }
            if (root == null)
            {
                return(null);
            }
            CPUElement rootEle = new CPUElement()
            {
                FunctionName   = root.propertyName,
                TotalPercent   = root.GetColumn(ProfilerColumn.TotalPercent),
                SelfPercent    = root.GetColumn(ProfilerColumn.SelfPercent),
                Calls          = root.GetColumn(ProfilerColumn.Calls),
                GCMemory       = root.GetColumn(ProfilerColumn.GCMemory),
                TotalTime      = root.GetColumn(ProfilerColumn.TotalTime),
                SelfTime       = root.GetColumn(ProfilerColumn.SelfTime),
                RelatedObjName = root.GetColumn(ProfilerColumn.ObjectName),
                Depth          = root.depth
            };

            if (allCPUEle != null)
            {
                allCPUEle.Add(rootEle);
            }

            while (root.Next(root.HasChildren))
            {
                CPUElement ele = new CPUElement()
                {
                    FunctionName   = root.propertyName,
                    TotalPercent   = root.GetColumn(ProfilerColumn.TotalPercent),
                    SelfPercent    = root.GetColumn(ProfilerColumn.SelfPercent),
                    Calls          = root.GetColumn(ProfilerColumn.Calls),
                    GCMemory       = root.GetColumn(ProfilerColumn.GCMemory),
                    TotalTime      = root.GetColumn(ProfilerColumn.TotalTime),
                    SelfTime       = root.GetColumn(ProfilerColumn.SelfTime),
                    RelatedObjName = root.GetColumn(ProfilerColumn.ObjectName),
                    Depth          = root.depth
                };
                if (allCPUEle != null)
                {
                    allCPUEle.Add(ele);
                }
            }

            SetChildren();
            return(rootEle);
        }
        /// <summary>
        /// 获取GPU数据,返回根元素
        /// </summary>
        /// <param name="writer"></param>
        /// <returns></returns>
        public static CPUElement GetCPUDetail(StreamWriter writer)
        {
            if (IsWindowEmpty())
            {
                return(null);
            }

            if (IsPropertyEmpty())
            {
                return(null);
            }

            return(CPUElement.Create(CPUOrGPUproperty));
        }
        /// <summary>
        /// 从跟打印所有CPU数据
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="root"></param>
        public static void WriteCPU(StreamWriter writer, CPUElement root)
        {
            if (root == null)
            {
                return;
            }

            writer.WriteLine(root.ToString());
            if (root.children == null)
            {
                return;
            }

            foreach (var child in root.children)
            {
                WriteCPU(writer, child);
            }
        }