Esempio n. 1
0
 private static Int32 CmpMaxTime(CCpuProfiler a, CCpuProfiler b)
 {
     if (a == null)
     {
         return(-1);
     }
     if (b == null)
     {
         return(1);
     }
     return(a.TTimeMax.CompareTo(b.TTimeMax));
 }
Esempio n. 2
0
 private static Int32 CmpName(CCpuProfiler a, CCpuProfiler b)
 {
     if (a == null)
     {
         return(-1);
     }
     if (b == null)
     {
         return(1);
     }
     return(a.StrName.CompareTo(b.StrName));
 }
Esempio n. 3
0
        /// <summary>
        /// 格式化输出一份分析表
        /// </summary>
        /// <param name="profilerList"></param>
        /// <param name="tSortType"></param>
        /// <returns></returns>
        public static string FormtTable(List <CCpuProfiler> profilerList, TCpuProfilerIndexType tSortType = TCpuProfilerIndexType.enTimeMax)
        {
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append("Name\tCallTime\tMinTime\tMaxTime\tTotalTime\t\n");
            if (profilerList == null)
            {
                return(strBuilder.ToString());
            }

            switch (tSortType)
            {
            case TCpuProfilerIndexType.enName:
                profilerList.Sort(CmpName);
                break;

            case TCpuProfilerIndexType.enTimeMax:
                profilerList.Sort(CmpMaxTime);
                break;

            case TCpuProfilerIndexType.enTimeMin:
                profilerList.Sort(CmpMinTime);
                break;

            case TCpuProfilerIndexType.enCallTime:
                profilerList.Sort(CmpCallTime);
                break;

            case TCpuProfilerIndexType.enTimeTotal:
                profilerList.Sort(CmpTotalTime);
                break;

            default:
                break;
            }
            Int32 nSize = profilerList.Count;

            for (Int32 i = 0; i < nSize; ++i)
            {
                CCpuProfiler profiler = profilerList[i];
                if (profiler == null)
                {
                    continue;
                }
                if (profiler.NCallTime <= 0)
                {
                    continue;
                }
                strBuilder.AppendLine(profiler.Format());
            }
            return(strBuilder.ToString());
        }