public void DetailedSpeedTestWithOptimization() { var mp = new MathParser(); mp.LocalVariables.Add("x", 5); var expr = "(3x+2)(2(2x+1))"; int itr = 3000; double creationTimeAndTokenization = BenchmarkUtil.Benchmark(() => mp.GetTokens(expr), 1); var tokens = mp.GetTokens(expr); double parsingTime = BenchmarkUtil.Benchmark(() => mp.Parse(tokens), itr); double totalTime = creationTimeAndTokenization + parsingTime; //var mp = new MathParser(); //mp.LocalVariables.Add("x", 5); //var expr = "(3x+2)(2(2x+1))"; //int itr = 50; double parsingTime2 = BenchmarkUtil.Benchmark(() => mp.Parse(expr), itr); double totalTime2 = parsingTime2; }
public void UnaryCallPerformance() { var call = new Call <string, string>(ServiceName, EchoMethod, channel, Metadata.Empty); BenchmarkUtil.RunBenchmark(100, 100, () => { Calls.BlockingUnaryCall(call, "ABC", default(CancellationToken)); }); }
public void NopPInvokeBenchmark() { BenchmarkUtil.RunBenchmark( 1000000, 100000000, () => { Native.grpcsharp_test_nop(IntPtr.Zero); }); }
public void TestIfPowIntInFasterThanPow() { const int iter = 250000; var z = new Complex(1.6859, 0.3902); var averageIntTime = BenchmarkUtil.Benchmark(() => { ComplexArithmetic.PowInt(z, 10); }, iter); var averageCpTime = BenchmarkUtil.Benchmark(() => { Complex.Pow(z, 10); }, iter); Assert.IsTrue(averageIntTime < averageCpTime); }
public void CompletionQueueCreateDestroyBenchmark() { BenchmarkUtil.RunBenchmark( 100000, 1000000, () => { CompletionQueueSafeHandle cq = CompletionQueueSafeHandle.Create(); cq.Dispose(); } ); }
public void NewNativeCallbackBenchmark() { counter = 0; BenchmarkUtil.RunBenchmark( 10000, 10000, () => { grpcsharp_test_callback(new CompletionCallbackDelegate(Handler)); } ); Assert.AreNotEqual(0, counter); }
public void NopPInvokeBenchmark() { CompletionCallbackDelegate handler = Handler; BenchmarkUtil.RunBenchmark( 1000000, 100000000, () => { grpcsharp_test_nop(IntPtr.Zero); } ); }
public void UnaryCallPerformance() { helper.UnaryHandler = new UnaryServerMethod <string, string>(async(request, context) => { return(request); }); var callDetails = helper.CreateUnaryCall(); BenchmarkUtil.RunBenchmark(100, 100, () => { Calls.BlockingUnaryCall(callDetails, "ABC"); }); }
public void SpeedTests() { var parser = new MathParser(); parser.LocalVariables.Add("x", 10); var list = parser.GetTokens("(3x+2)"); var time = BenchmarkUtil.Benchmark(() => parser.Parse("(3x+2)"), 25000); var time2 = BenchmarkUtil.Benchmark(() => parser.Parse(list), 25000); Assert.IsTrue(time >= time2); }
public void NativeCallbackBenchmark() { OpCompletionDelegate handler = Handler; counter = 0; BenchmarkUtil.RunBenchmark( 1000000, 10000000, () => { Native.grpcsharp_test_callback(handler); }); Assert.AreNotEqual(0, counter); }
public void DetailedSpeedTestWithoutOptimization() { var parser = new MathParser(); parser.LocalVariables.Add("x", 5); var expr = "(3x+2)(2(2x+1))"; const int itr = 50; var parsingTime = BenchmarkUtil.Benchmark(() => parser.Parse(expr), itr); Console.WriteLine("Parsing Time: " + parsingTime); Console.WriteLine("Total Time: " + parsingTime); }
public void CompletionQueueCreateDestroyBenchmark() { GrpcEnvironment.AddRef(); // completion queue requires gRPC environment being initialized. BenchmarkUtil.RunBenchmark( 10, 10, () => { CompletionQueueSafeHandle cq = CompletionQueueSafeHandle.Create(); cq.Dispose(); }); GrpcEnvironment.ReleaseAsync().Wait(); }
public void DetailedSpeedTestWithOutOptimization() { var mp = new MathParser(); mp.LocalVariables.Add("x", 5); var expr = "(3x+2)(2(2x+1))"; int itr = 50; double parsingTime = BenchmarkUtil.Benchmark(() => mp.Parse(expr), itr); double totalTime = parsingTime; }
public void UnaryCallPerformance() { Server server = new Server(); server.AddServiceDefinition( ServerServiceDefinition.CreateBuilder(serviceName) .AddMethod(unaryEchoStringMethod, HandleUnaryEchoString).Build()); int port = server.AddListeningPort(host + ":0"); server.Start(); using (Channel channel = new Channel(host + ":" + port)) { var call = new Call <string, string>(serviceName, unaryEchoStringMethod, channel, Metadata.Empty); BenchmarkUtil.RunBenchmark(100, 1000, () => { Calls.BlockingUnaryCall(call, "ABC", default(CancellationToken)); }); } server.ShutdownAsync().Wait(); }
public void DetailedSpeedTestWithOptimization() { var parser = new MathParser(); parser.LocalVariables.Add("x", 5); var expr = "(3x+2)(2(2x+1))"; const int itr = 3000; var creationTimeAndTokenization = BenchmarkUtil.Benchmark(() => parser.GetTokens(expr), 1); var tokens = parser.GetTokens(expr); var parsingTime = BenchmarkUtil.Benchmark(() => parser.Parse(tokens), itr); var totalTime = creationTimeAndTokenization + parsingTime; Console.WriteLine("Parsing Time: " + parsingTime); Console.WriteLine("Total Time: " + totalTime); var parsingTime2 = BenchmarkUtil.Benchmark(() => parser.Parse(expr), itr); Console.WriteLine("Parsing Time 2: " + parsingTime2); Console.WriteLine("Total Time: " + parsingTime2); }
// for testing purposes: public double Time(Action action, int iterations = 1000) { return(BenchmarkUtil.Benchmark(action, iterations)); }
public void NowBenchmark() { // approx Timespec.Now latency <33ns BenchmarkUtil.RunBenchmark(10000000, 1000000000, () => { var now = Timespec.Now; }); }
public void PreciseNowBenchmark() { // approx Timespec.PreciseNow latency <18ns (when compiled with GRPC_TIMERS_RDTSC) BenchmarkUtil.RunBenchmark(10000000, 1000000000, () => { var now = Timespec.PreciseNow; }); }
// This is not an official interop test, but it's useful. public static void RunBenchmarkEmptyUnary(TestService.ITestServiceClient client) { BenchmarkUtil.RunBenchmark(10000, 10000, () => { client.EmptyCall(new Empty()); }); }
// This is not an official interop test, but it's useful. public static void RunBenchmarkEmptyUnary(TestService.ITestServiceClient client) { BenchmarkUtil.RunBenchmark(10000, 10000, () => { client.EmptyCall(Empty.DefaultInstance); }); }