Beispiel #1
0
        public override async Task Execute(CancellationToken cancellationToken)
        {
            ShowProgressBar = true;
            await DotMemory.EnsurePrerequisiteAsync(cancellationToken, this, null, NuGetApi.V3, _path);

            Progress.Report((100, 100));
        }
        public void TakeSnapshot()
        {
            lock (this)
            {
                if (!Profiling)
                {
                    return;
                }

                DotMemory.GetSnapshot();
            }
        }
        public void StopProfiling()
        {
            lock (this)
            {
                if (!Profiling)
                {
                    return;
                }

                string workspacePath = DotMemory.Detach();

                Profiling = false;
            }
        }
        public void StartProfiling(string dirPath)
        {
            lock (this)
            {
                if (Profiling)
                {
                    return;
                }

                DotMemory.EnsurePrerequisite(null, NuGetApi.V3, _plugin.ResolveRelativePath(ProfilerDirectory));

                DotMemory.Config config = new();
                config.SaveToDir(dirPath);

                DotMemory.Attach(config);
                Profiling = true;
            }
        }
        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
        }