public virtual void TearDown() { if (proxy != null) { RPC.StopProxy(proxy.GetProxy()); proxy = null; } if (server != null) { server.Stop(); server = null; } }
public virtual void TearDown() { server.Stop(); }
/// <exception cref="System.Exception"/> public virtual int Run(string[] args) { RPCCallBenchmark.MyOptions opts = new RPCCallBenchmark.MyOptions(args); if (opts.failed) { return(-1); } // Set RPC engine to the configured RPC engine RPC.SetProtocolEngine(conf, typeof(TestProtoBufRpc.TestRpcService), opts.rpcEngine ); RPC.Server server = StartServer(opts); try { MultithreadedTestUtil.TestContext ctx = SetupClientTestContext(opts); if (ctx != null) { long totalCalls = 0; ctx.StartThreads(); long veryStart = Runtime.NanoTime(); // Loop printing results every second until the specified // time has elapsed for (int i = 0; i < opts.secondsToRun; i++) { long st = Runtime.NanoTime(); ctx.WaitFor(1000); long et = Runtime.NanoTime(); long ct = callCount.GetAndSet(0); totalCalls += ct; double callsPerSec = (ct * 1000000000) / (et - st); System.Console.Out.WriteLine("Calls per second: " + callsPerSec); } // Print results if (totalCalls > 0) { long veryEnd = Runtime.NanoTime(); double callsPerSec = (totalCalls * 1000000000) / (veryEnd - veryStart); long cpuNanosClient = GetTotalCpuTime(ctx.GetTestThreads()); long cpuNanosServer = -1; if (server != null) { cpuNanosServer = GetTotalCpuTime(server.GetHandlers()); } System.Console.Out.WriteLine("====== Results ======"); System.Console.Out.WriteLine("Options:\n" + opts); System.Console.Out.WriteLine("Total calls per second: " + callsPerSec); System.Console.Out.WriteLine("CPU time per call on client: " + (cpuNanosClient / totalCalls) + " ns"); if (server != null) { System.Console.Out.WriteLine("CPU time per call on server: " + (cpuNanosServer / totalCalls) + " ns"); } } else { System.Console.Out.WriteLine("No calls!"); } ctx.Stop(); } else { while (true) { Thread.Sleep(10000); } } } finally { if (server != null) { server.Stop(); } } return(0); }