Ejemplo n.º 1
0
        public static string GetReports(BenchmarkReportOrder order, string type, bool toMs)
        {
            var sb = new StringBuilder();

            sb.AppendFormat("Getting report from {0}", type);

            sb.AppendLine();
            sb.AppendLine();
            sb.AppendLine(F.GetSeparator());
            sb.AppendLine();

            var d = GetData(type);
            // DebugReport(d.data);

            var totalTime = d.data.Select(x => GetVal(x.Value.ticks, x.Value.countFirst ? 1 : x.Value.times, true))
                            .Sum();

            sb.Append(GetCompleteReport(ref d.data, order, totalTime, toMs));

            var totalCalls = d.data.Sum(x => x.Value.countFirst ? 1 : x.Value.times);

            sb.AppendFormat("Total time: {0} s of {1} s (~{2}%) Avg: {3} | Calls: {4} | Avg / per call: {5}",
                            (totalTime / 1000f).ToString("F2"),
                            Time.realtimeSinceStartup.ToString("F2"),
                            (totalTime / 1000f / Time.realtimeSinceStartup * 100).ToString("F2"),
                            GetFormattedString(GetAvg(d.data.Count, totalTime), false),
                            totalCalls,
                            GetFormattedString(GetAvg(d.data.Count, totalTime, totalCalls), false));

            return(sb.ToString());
        }
Ejemplo n.º 2
0
        public void GetActualReport(BenchmarkReportOrder order)
        {
            // Debug.LogFormat("Reports num: {0}", BenchmarkData.benchmarks.Count);

            foreach (var report in BenchmarkData.benchmarks)
            {
                Debug.Log(BenchmarkData.GetReports(order, report.Value.type, true));
            }
        }
Ejemplo n.º 3
0
        private static ConcurrentDictionary <string, BData> GetReport(ConcurrentDictionary <string, BData> report,
                                                                      BenchmarkReportOrder order)
        {
            if (order == BenchmarkReportOrder.Desdescing || order == BenchmarkReportOrder.All)
            {
                return(report.OrderBy(x => x.Value.ticks * (x.Value.countFirst ? 1 : x.Value.times))
                       .ToConcurrentDictionary());
            }

            if (order == BenchmarkReportOrder.AZ || order == BenchmarkReportOrder.All)
            {
                return(report.OrderByDescending(x => x.Key).ToConcurrentDictionary());
            }

            return(report);
        }
Ejemplo n.º 4
0
        private static string GetCompleteReport(ref ConcurrentDictionary <string, BData> report,
                                                BenchmarkReportOrder order, float totalTime, bool toMs)
        {
            var sb = new StringBuilder();

            if (order == BenchmarkReportOrder.AZ || order == BenchmarkReportOrder.All)
            {
                sb.AppendLine(GetReportHead(BenchmarkReportOrder.AZ));
                report = GetReport(report, BenchmarkReportOrder.AZ);
                sb.AppendLine(GetIndividualReport(report, totalTime, toMs));
            }

            if (order == BenchmarkReportOrder.Desdescing || order == BenchmarkReportOrder.All)
            {
                sb.AppendLine(GetReportHead(BenchmarkReportOrder.Desdescing));
                report = GetReport(report, BenchmarkReportOrder.Desdescing);
                sb.AppendLine(GetIndividualReport(report, totalTime, toMs));
            }

            return(sb.ToString());
        }
Ejemplo n.º 5
0
 private static string GetReportHead(BenchmarkReportOrder order)
 {
     return(string.Format("Ordered by {0}:{1}", order.ToString(), Environment.NewLine));
 }