Пример #1
0
        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;
        }
Пример #2
0
        public void UnaryCallPerformance()
        {
            var call = new Call <string, string>(ServiceName, EchoMethod, channel, Metadata.Empty);

            BenchmarkUtil.RunBenchmark(100, 100,
                                       () => { Calls.BlockingUnaryCall(call, "ABC", default(CancellationToken)); });
        }
Пример #3
0
 public void NopPInvokeBenchmark()
 {
     BenchmarkUtil.RunBenchmark(
         1000000, 100000000,
         () =>
     {
         Native.grpcsharp_test_nop(IntPtr.Zero);
     });
 }
Пример #4
0
        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);
        }
Пример #5
0
 public void CompletionQueueCreateDestroyBenchmark()
 {
     BenchmarkUtil.RunBenchmark(
         100000, 1000000,
         () => {
         CompletionQueueSafeHandle cq = CompletionQueueSafeHandle.Create();
         cq.Dispose();
     }
         );
 }
Пример #6
0
 public void NewNativeCallbackBenchmark()
 {
     counter = 0;
     BenchmarkUtil.RunBenchmark(
         10000, 10000,
         () => {
         grpcsharp_test_callback(new CompletionCallbackDelegate(Handler));
     }
         );
     Assert.AreNotEqual(0, counter);
 }
Пример #7
0
        public void NopPInvokeBenchmark()
        {
            CompletionCallbackDelegate handler = Handler;

            BenchmarkUtil.RunBenchmark(
                1000000, 100000000,
                () => {
                grpcsharp_test_nop(IntPtr.Zero);
            }
                );
        }
Пример #8
0
        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"); });
        }
Пример #9
0
        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);
        }
Пример #10
0
        public void NativeCallbackBenchmark()
        {
            OpCompletionDelegate handler = Handler;

            counter = 0;
            BenchmarkUtil.RunBenchmark(
                1000000, 10000000,
                () =>
            {
                Native.grpcsharp_test_callback(handler);
            });
            Assert.AreNotEqual(0, counter);
        }
Пример #11
0
        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);
        }
Пример #12
0
        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();
        }
Пример #13
0
        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;
        }
Пример #14
0
        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();
        }
Пример #15
0
        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);
        }
Пример #16
0
 // for testing purposes:
 public double Time(Action action, int iterations = 1000)
 {
     return(BenchmarkUtil.Benchmark(action, iterations));
 }
Пример #17
0
 public void NowBenchmark()
 {
     // approx Timespec.Now latency <33ns
     BenchmarkUtil.RunBenchmark(10000000, 1000000000, () => { var now = Timespec.Now; });
 }
Пример #18
0
 public void PreciseNowBenchmark()
 {
     // approx Timespec.PreciseNow latency <18ns (when compiled with GRPC_TIMERS_RDTSC)
     BenchmarkUtil.RunBenchmark(10000000, 1000000000, () => { var now = Timespec.PreciseNow; });
 }
Пример #19
0
 // 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()); });
 }
Пример #20
0
 // 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); });
 }