コード例 #1
0
        public void _Info()
        {
            // Arrange
            var isolatedBenchmark = new IsolatedBenchmarkTest();

            // Act
            isolatedBenchmark.Act();

            // Assert
            // Memory I get from Benchmark
            Console.WriteLine($"AppDomain MonitoringTotalProcessorTime {AppDomain.CurrentDomain.MonitoringTotalProcessorTime}");
            Console.WriteLine($"AppDomain MonitoringTotalAllocatedMemorySize {AppDomain.CurrentDomain.MonitoringTotalAllocatedMemorySize}");

            // Memory I get from the specific domain
            Console.WriteLine($"Isolated MonitoringTotalProcessorTime {isolatedBenchmark.Isolated.domain.MonitoringTotalProcessorTime}");
            Console.WriteLine($"Isolated MonitoringTotalAllocatedMemorySize {isolatedBenchmark.Isolated.domain.MonitoringTotalAllocatedMemorySize}");
            Console.WriteLine($"AppDomain MonitoringSurvivedProcessMemorySize {AppDomain.MonitoringSurvivedProcessMemorySize}");

            isolatedBenchmark.Dispose();
        }
コード例 #2
0
        public void Benchmarking_MemoryWatcher_IsolatedMemoryTest()
        {
            // Arrange
            var isolatedBenchmark = new IsolatedBenchmarkTest();

            isolatedBenchmark.Arrange();

            IMemoryWatcher memoryWatcher = new MemoryWatcher();

            // Act
            memoryWatcher.Start(TimeSpan.FromMilliseconds(10));
            isolatedBenchmark.Act();
            memoryWatcher.Stop();

            // Assert
            Console.WriteLine("List of measured memory");
            Console.WriteLine(string.Join(Environment.NewLine, memoryWatcher.GetMeasuredMemory()));
            Console.WriteLine($"MaxMemory = {memoryWatcher.GetMaxMemory()}");
            Console.WriteLine($"MeanMemory = {memoryWatcher.GetMeanMemory()}");
            isolatedBenchmark.Dispose();
        }