Beispiel #1
0
        static void Main(string[] args)
        {
            pipeLineDeph = int.Parse(args.FirstOrDefault(f => f.StartsWith("-p"))?.Substring(2) ?? "16");
            int connections = int.Parse(args.FirstOrDefault(f => f.StartsWith("-c"))?.Substring(2) ?? "512");
            clientPool = new RioTcpClientPool(new RioFixedBufferPool(1000, (256 * pipeLineDeph)), new RioFixedBufferPool(1000, (256 * pipeLineDeph)), (uint)connections);
            timer = new Stopwatch();
            span = TimeSpan.FromSeconds(int.Parse(args.FirstOrDefault(f => f.StartsWith("-d"))?.Substring(2) ?? "5"));
            uri = new Uri(args.FirstOrDefault(a => !a.StartsWith("-")) ?? "http://localhost:5000");
            keepAlive = true;
            requestBytes = Enumerable.Repeat(_requestBytes, pipeLineDeph).SelectMany(b => b).ToArray();

            Console.WriteLine("RioSharp http benchmark");
            Console.WriteLine("Connections: " + connections);
            Console.WriteLine("Duration: " + span.TotalSeconds + " seconds");
            Console.WriteLine("Pipeline depth: " + pipeLineDeph);
            Console.WriteLine("Target: " + uri);
            Console.WriteLine("Benchmarking...");

            timer.Start();
            var tasks = Enumerable.Range(0, connections).Select(t => Task.Run(Execute));

            var totalRequests = tasks.Sum(t => t.Result);
            Console.WriteLine($"Made {totalRequests } requests over {span.TotalSeconds} seconds ({totalRequests / span.TotalSeconds} Rps)");
            clientPool.Dispose();
        }
Beispiel #2
0
        static void Main(string[] args)
        {

            clientPool = new RioTcpClientPool(new RioFixedBufferPool(100, 100), new RioFixedBufferPool(10, 100), 4096);
            listener = new RioTcpListener(new RioFixedBufferPool(100, 100), new RioFixedBufferPool(100, 100), 4096);
            listener.Listen(new IPEndPoint(new IPAddress(new byte[] { 0, 0, 0, 0 }), 5000), 1024);
            e = new ManualResetEvent(false);

            var task = Task.Run((Action)clientDisconnect);
            Log();
            Console.ReadLine();
            running = false;
            task.Wait();
            clientPool.Dispose();
            listener.Dispose();
        }