コード例 #1
0
        private static void Verify(GameObject sender, EventArgs args, string eventName, bool recursiveSender = false, bool recursiveArgs = true)
        {
            if (!Directory.Exists(Program.ResultPath))
            {
                Directory.CreateDirectory(Program.ResultPath);
            }

            using (var writer = File.CreateText(Path.Combine(Program.ResultPath, eventName + ".txt")))
            {
                using (var analyzer = new GameObjectDiagnosis(sender, writer))
                {
                    var stopwatch = new Stopwatch();
                    stopwatch.Start();
                    analyzer.Analyze(sender, true, recursiveSender);
                    analyzer.Analyze(args, false, recursiveArgs);
                    stopwatch.Stop();
                    Logger.Log(LogLevel.Debug, "Total analyze time of {0}<{2}> (including disk IO): {1}ms", eventName, stopwatch.ElapsedTicks / (double)TimeSpan.TicksPerMillisecond, sender.GetType().Name);

                    var times = analyzer.ComputeTimes.OrderByDescending(o => o.Key).ToArray();
                    if (times.Length > 0)
                    {
                        writer.WriteLine();
                        writer.WriteLine();
                        writer.WriteLine("Top {0} compute times:", Math.Min(10, times.Length));
                        for (var i = 0; i < Math.Min(10, times.Length); i++)
                        {
                            writer.WriteLine(" - {0}: {1}ms", times[i].Value, times[i].Key);
                        }
                    }
                }
            }
        }
コード例 #2
0
        private static void VerifyObjects()
        {
            var currentlyEnabled = GetCurrentlyEnabled();
            var objects          = ObjectManager.Get <GameObject>().Where(o => currentlyEnabled.Contains(o.Type)).ToArray();

            if (objects.Length > 0)
            {
                if (!Directory.Exists(Program.ResultPath))
                {
                    Directory.CreateDirectory(Program.ResultPath);
                }

                using (var writer = File.CreateText(Path.Combine(Program.ResultPath, "PropertyDiagnosis.txt")))
                {
                    writer.WriteLine("Verifying a total of {0} GameObjects!", objects.Length);
                    writer.WriteLine();
                    writer.Flush();

                    var times = new Dictionary <double, string>();

                    foreach (var obj in objects)
                    {
                        using (var analyzer = new GameObjectDiagnosis(obj, writer))
                        {
                            analyzer.Analyze();
                            foreach (var time in analyzer.ComputeTimes)
                            {
                                times[time.Key] = time.Value;
                            }
                        }
                    }

                    var computeResults = new List <AnalyzeComputeResult>();
                    foreach (var time in times)
                    {
                        if (computeResults.All(o => o.Property != time.Value))
                        {
                            computeResults.Add(new AnalyzeComputeResult
                            {
                                Property = time.Value,
                                All      = new List <double> {
                                    time.Key
                                }
                            });
                        }
                        else
                        {
                            computeResults.First(o => o.Property == time.Value).All.Add(time.Key);
                        }
                    }

                    var orderedTimes = computeResults.OrderByDescending(o => o.Average).ToArray();
                    if (orderedTimes.Length > 0)
                    {
                        writer.WriteLine();
                        writer.WriteLine();
                        writer.WriteLine("Top {0} compute times:", Math.Min(100, orderedTimes.Length));
                        for (var i = 0; i < Math.Min(100, orderedTimes.Length); i++)
                        {
                            writer.WriteLine(" - {0}:", orderedTimes[i].Property);
                            writer.WriteLine("     - Average: {0}", orderedTimes[i].Average);
                            writer.WriteLine("     - Min:     {0}", orderedTimes[i].Min);
                            writer.WriteLine("     - Max:     {0}", orderedTimes[i].Max);
                            writer.WriteLine("     - Amount:  {0}", orderedTimes[i].Amount);
                        }
                    }
                }
            }
        }
コード例 #3
0
        private static void Verify(GameObject sender, EventArgs args, string eventName, bool recursiveSender = false, bool recursiveArgs = true)
        {
            if (!Directory.Exists(Program.ResultPath))
            {
                Directory.CreateDirectory(Program.ResultPath);
            }

            using (var writer = File.CreateText(Path.Combine(Program.ResultPath, eventName + ".txt")))
            {
                using (var analyzer = new GameObjectDiagnosis(sender, writer))
                {
                    var stopwatch = new Stopwatch();
                    stopwatch.Start();
                    analyzer.Analyze(sender, true, recursiveSender);
                    analyzer.Analyze(args, false, recursiveArgs);
                    stopwatch.Stop();
                    Logger.Log(LogLevel.Debug, "Total analyze time of {0}<{2}> (including disk IO): {1}ms", eventName, stopwatch.ElapsedTicks / (double) TimeSpan.TicksPerMillisecond,
                        sender.GetType().Name);

                    var times = analyzer.ComputeTimes.OrderByDescending(o => o.Key).ToArray();
                    if (times.Length > 0)
                    {
                        writer.WriteLine();
                        writer.WriteLine();
                        writer.WriteLine("Top {0} compute times:", Math.Min(10, times.Length));
                        for (var i = 0; i < Math.Min(10, times.Length); i++)
                        {
                            writer.WriteLine(" - {0}: {1}ms", times[i].Value, times[i].Key);
                        }
                    }
                }
            }
        }
コード例 #4
0
        private static void VerifyObjects()
        {
            var currentlyEnabled = GetCurrentlyEnabled();
            var objects = ObjectManager.Get<GameObject>().Where(o => currentlyEnabled.Contains(o.Type)).ToArray();
            if (objects.Length > 0)
            {
                if (!Directory.Exists(Program.ResultPath))
                {
                    Directory.CreateDirectory(Program.ResultPath);
                }

                using (var writer = File.CreateText(Path.Combine(Program.ResultPath, "PropertyDiagnosis.txt")))
                {
                    writer.WriteLine("Verifying a total of {0} GameObjects!", objects.Length);
                    writer.WriteLine();
                    writer.Flush();

                    var times = new Dictionary<double, string>();

                    foreach (var obj in objects)
                    {
                        using (var analyzer = new GameObjectDiagnosis(obj, writer))
                        {
                            analyzer.Analyze();
                            foreach (var time in analyzer.ComputeTimes)
                            {
                                times[time.Key] = time.Value;
                            }
                        }
                    }

                    var computeResults = new List<AnalyzeComputeResult>();
                    foreach (var time in times)
                    {
                        if (computeResults.All(o => o.Property != time.Value))
                        {
                            computeResults.Add(new AnalyzeComputeResult
                            {
                                Property = time.Value,
                                All = new List<double> { time.Key }
                            });
                        }
                        else
                        {
                            computeResults.First(o => o.Property == time.Value).All.Add(time.Key);
                        }
                    }

                    var orderedTimes = computeResults.OrderByDescending(o => o.Average).ToArray();
                    if (orderedTimes.Length > 0)
                    {
                        writer.WriteLine();
                        writer.WriteLine();
                        writer.WriteLine("Top {0} compute times:", Math.Min(100, orderedTimes.Length));
                        for (var i = 0; i < Math.Min(100, orderedTimes.Length); i++)
                        {
                            writer.WriteLine(" - {0}:", orderedTimes[i].Property);
                            writer.WriteLine("     - Average: {0}", orderedTimes[i].Average);
                            writer.WriteLine("     - Min:     {0}", orderedTimes[i].Min);
                            writer.WriteLine("     - Max:     {0}", orderedTimes[i].Max);
                            writer.WriteLine("     - Amount:  {0}", orderedTimes[i].Amount);
                        }
                    }
                }
            }
        }