Beispiel #1
0
        public static async void TraceMe(bool start = true)
        {
#if !LIB
            if (start)
            {
                await DotTrace.EnsurePrerequisiteAsync();

                Directory.CreateDirectory("C:\\Temp\\Snapshot");
                var config = new DotTrace.Config();
                config.SaveToDir("C:\\Temp\\Snapshot");
                DotTrace.Attach(config);
                DotTrace.StartCollectingData();
            }
            else
            {
                DotTrace.StopCollectingData();
                DotTrace.SaveData();
            }
#endif
        }
        public static void Main()
        {
            String packageDir  = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName, "packages");
            String snapshotDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName, "Snapshots");

#if TESTPERFORMANCE
            DotTrace.EnsurePrerequisite(downloadTo: packageDir);
            DotTrace.Config config = new DotTrace.Config();
            Directory.CreateDirectory(Path.Combine(snapshotDir, "Performance", Version));
            config.SaveToDir(Path.Combine(snapshotDir, "Performance", Version));
            DotTrace.Attach(config);
            for (int index = 1; index <= 100; index++)
            {
                Console.WriteLine("Running Test Border Generation no. {0}", index);
                SpeedCounter counter = SpeedCounter.GetCounter("ProvinceBordersConstructor");
                DotTrace.StartCollectingData();
                counter.Start();
                TestBordersGeneration();
                counter.Stop();
                DotTrace.StopCollectingData();
                Console.WriteLine("Test no. {0} finished in {1} seconds", index, (double)SpeedCounter.GetCounter("ProvinceBordersConstructor").mLast / 1000);
            }
            DotTrace.SaveData();
            DotTrace.Detach();
            Console.WriteLine("Average test speed {0}", (double)SpeedCounter.GetCounter("ProvinceBordersConstructor").mAverage / 1000);
            Console.WriteLine("Total test time {0}", (double)SpeedCounter.GetCounter("ProvinceBordersConstructor").mSum / 1000);
            Console.ReadKey();
#elif TESTMEMORY
            DotMemory.EnsurePrerequisite(downloadTo: packageDir);
            DotMemory.Config config = new DotMemory.Config();
            Directory.CreateDirectory(Path.Combine(snapshotDir, "Memory", Version));
            config.SaveToDir(Path.Combine(snapshotDir, "Memory", Version));
            DotMemory.Attach(config);
            DotMemory.GetSnapshot("Setup finished");
            TestBordersGeneration();
            DotMemory.GetSnapshot("Border Generation Finished");
            DotMemory.Detach();
#endif
        }