Exemplo n.º 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();
        }
Exemplo n.º 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();
        }
Exemplo n.º 3
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");

            timer     = new Stopwatch();
            span      = TimeSpan.FromSeconds(int.Parse(args.FirstOrDefault(f => f.StartsWith("-d"))?.Substring(2) ?? "25"));
            uri       = new Uri(args.FirstOrDefault(a => !a.StartsWith("-")) ?? "http://localhost:5000/plaintext");
            keepAlive = bool.Parse(args.FirstOrDefault(f => f.StartsWith("-k"))?.Substring(2) ?? "true");

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

            Task.Delay(span).ContinueWith(t => { Console.WriteLine("should be done by now..."); });

            var _requestBytes = Encoding.ASCII.GetBytes($"GET {uri.PathAndQuery} HTTP/1.1\r\nHost: {uri.Host}:{uri.Port}\r\n\r\n");

            reqz = new byte[pipeLineDeph + 1][];

            for (int i = 0; i < reqz.Length; i++)
            {
                reqz[i] = Enumerable.Repeat(_requestBytes, i).SelectMany(b => b).ToArray();
            }

            sendPool   = new RioFixedBufferPool(10 * connections, _requestBytes.Length * pipeLineDeph);
            clientPool = new RioTcpClientPool(sendPool, new RioFixedBufferPool(10 * connections, (256 * pipeLineDeph)), (uint)connections, 4096, 4096);
            Console.WriteLine("Benchmarking...");

            timer.Start();
            var tasks = Enumerable.Range(0, connections).Select(t => keepAlive ? Task.Run(ExecuteSegment) : Task.Run(ExecuteStream)).ToList();

            var totalRequests = tasks.Sum(t => t.Result.Requests);

            Console.WriteLine($"Made {totalRequests } requests over {span.TotalSeconds} seconds ({totalRequests / span.TotalSeconds} Rps)");
            clientPool.Dispose();
        }
Exemplo n.º 4
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");
            timer = new Stopwatch();
            span = TimeSpan.FromSeconds(int.Parse(args.FirstOrDefault(f => f.StartsWith("-d"))?.Substring(2) ?? "25"));
            uri = new Uri(args.FirstOrDefault(a => !a.StartsWith("-")) ?? "http://localhost:5000/plaintext");
            keepAlive = bool.Parse(args.FirstOrDefault(f => f.StartsWith("-k"))?.Substring(2) ?? "true");

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

            Task.Delay(span).ContinueWith(t => { Console.WriteLine("should be done by now..."); });

            var _requestBytes = Encoding.ASCII.GetBytes($"GET {uri.PathAndQuery} HTTP/1.1\r\nHost: {uri.Host}:{uri.Port}\r\n\r\n");

            reqz = new byte[pipeLineDeph + 1][];

            for (int i = 0; i < reqz.Length; i++)
            {
                reqz[i] = Enumerable.Repeat(_requestBytes, i).SelectMany(b => b).ToArray();
            }

            sendPool = new RioFixedBufferPool(10 * connections, _requestBytes.Length * pipeLineDeph);
            clientPool = new RioTcpClientPool(sendPool, new RioFixedBufferPool(10 * connections, (256 * pipeLineDeph)), (uint)connections,4096,4096);
            Console.WriteLine("Benchmarking...");

            timer.Start();
            var tasks = Enumerable.Range(0, connections).Select(t => keepAlive ? Task.Run(ExecuteSegment) : Task.Run(ExecuteStream)).ToList();

            var totalRequests = tasks.Sum(t => t.Result.Requests);
            Console.WriteLine($"Made {totalRequests } requests over {span.TotalSeconds} seconds ({totalRequests / span.TotalSeconds} Rps)");
            clientPool.Dispose();
        }
Exemplo n.º 5
0
        public static async Task ClientTcp()
        {
            RioTcpClientPool l    = new RioTcpClientPool(new RioFixedBufferPool(Connections, Transfer), new RioFixedBufferPool(Connections, Transfer), (uint)Connections);
            int totalBytesRecived = 0;
            int currentRecived    = 0;
            TaskCompletionSource <object> tcs;

            for (int i = 0; i < Iterations; i++)
            {
                var s = await l.Connect(new Uri(Target));

                var reader = new RioSegmentReader(s);

                if (Pattern == "PushPull")
                {
                    while (totalBytesRecived < Transfer)
                    {
                        tcs = new TaskCompletionSource <object>();
                        s.Send(new byte[PushBytes]);
                        reader.OnIncommingSegment = seg =>
                        {
                            totalBytesRecived += seg.CurrentContentLength;
                            currentRecived    += seg.CurrentContentLength;
                            if (currentRecived >= PullBytes)
                            {
                                tcs.SetResult(null);
                            }
                        };
                        await tcs.Task;
                    }
                }
                else if (Pattern == "Push")
                {
                    s.Send(new byte[Transfer]);
                }
                else if (Pattern == "Pull")
                {
                    tcs = new TaskCompletionSource <object>();

                    reader.OnIncommingSegment = seg =>
                    {
                        totalBytesRecived += seg.CurrentContentLength;
                        if (totalBytesRecived >= Transfer)
                        {
                            tcs.SetResult(null);
                        }
                    };
                    await tcs.Task;
                }
                else if (Pattern == "Duplex")
                {
                    tcs = new TaskCompletionSource <object>();
                    s.Send(new byte[Transfer / 2]);
                    reader.OnIncommingSegment = seg =>
                    {
                        totalBytesRecived += seg.CurrentContentLength;
                        if (totalBytesRecived >= Transfer / 2)
                        {
                            tcs.SetResult(null);
                        }
                    };
                }
            }
        }