public async Task <double[]> ProfileMemoryAsync(Arguments args) { try { Console.WriteLine("Setting up..."); await SetupAsync(args); var warmups = new long[args.NrWarmups]; var repetitions = new long[args.NrRepetitions]; BenchmarkUtil.ReclaimResources(); Console.WriteLine("Started memory profiling with {0} warmups, {1} repetitions...", warmups.Length, repetitions.Length); // TODO combine memory/repetitions? // warmups for (int i = 0; i < warmups.Length; i++) { Console.WriteLine("Warmup {0}...", i); await ExecuteAsync(); // dispose process object directly after usage using (var proc = Process.GetCurrentProcess()) { warmups[i] = proc.PrivateMemorySize64; } } // repetitions for (int i = 0; i < repetitions.Length; i++) { Console.WriteLine("Repetition {0}...", i); await ExecuteAsync(); // dispose process object directly after usage using (var proc = Process.GetCurrentProcess()) { repetitions[i] = proc.PrivateMemorySize64; } } Console.WriteLine("Stopped memory profiling."); // combine warmup and benchmark results var results = new double[warmups.Length + repetitions.Length]; Array.Copy(warmups, results, warmups.Length); Array.Copy(repetitions, 0, results, warmups.Length, repetitions.Length); // convert results from bytes to megabytes for (int i = 0; i < results.Length; i++) { results[i] = results[i] / 1000000; } return(results); } finally { Console.WriteLine("Shutting down..."); ShutdownAsync().Wait(); } }
public static void Setup() { Peer server = null; try { var peers = BenchmarkUtil.CreateNodes(1, new InteropRandom(123), 9876, false, false); server = peers[0]; server.RawDataReply(new ServerRawDataReply()); var pa = server.PeerAddress; Console.WriteLine("Server Peer: {0}.", pa); Console.WriteLine("--------------------------------------------------------------------------------------"); Console.WriteLine("Copy Arguments: {0} {1} {2} {3}.", pa.PeerId, pa.InetAddress, pa.TcpPort, pa.UdpPort); Console.WriteLine("--------------------------------------------------------------------------------------"); Console.WriteLine("Press Enter to shut server down..."); Console.ReadLine(); } finally { if (server != null) { server.ShutdownAsync().Wait(); } } }
public async Task <double[]> ProfileCpuAsync(Arguments args) { try { BenchmarkUtil.PrintStopwatchProperties(); Console.WriteLine("Setting up..."); await SetupAsync(args); var warmups = new long[args.NrWarmups]; var repetitions = new long[args.NrRepetitions]; BenchmarkUtil.WarmupTimer(); BenchmarkUtil.ReclaimResources(); Console.WriteLine("Started CPU profiling with {0} warmups, {1} repetitions...", warmups.Length, repetitions.Length); var watch = Stopwatch.StartNew(); // warmups for (int i = 0; i < warmups.Length; i++) { Console.WriteLine("Warmup {0}...", i); watch.Restart(); await ExecuteAsync(); warmups[i] = watch.ElapsedTicks; } // repetitions for (int i = 0; i < repetitions.Length; i++) { Console.WriteLine("Repetition {0}...", i); watch.Restart(); await ExecuteAsync(); repetitions[i] = watch.ElapsedTicks; } watch.Stop(); Console.WriteLine("Stopped CPU profiling."); // combine warmup and benchmark results var results = new double[warmups.Length + repetitions.Length]; Array.Copy(warmups, results, warmups.Length); Array.Copy(repetitions, 0, results, warmups.Length, repetitions.Length); // convert results from ticks to ms for (int i = 0; i < results.Length; i++) { results[i] = (results[i] / Stopwatch.Frequency) * 1000; } return(results); } finally { Console.WriteLine("Shutting down..."); ShutdownAsync().Wait(); } }
protected override async Task SetupAsync(Arguments args) { Network = BenchmarkUtil.CreateNodes(NetworkSize, Rnd, 7077, false, false); Sender = Network[0]; _remoteAddress = args.Param as PeerAddress; Cc = await Sender.ConnectionBean.Reservation.CreateAsync(IsForceUdp? 1 : 0, IsForceUdp? 0 : 1); SendDirectBuilder = new SendDirectBuilder(Sender, (PeerAddress)null) .SetIdleUdpSeconds(0) .SetIdleTcpSeconds(0) .SetBuffer(CreateSampleBuffer()) .SetIsForceUdp(IsForceUdp); }
protected override async Task SetupAsync(Arguments args) { Network = BenchmarkUtil.CreateNodes(NetworkSize, Rnd, 7077, false, false); }