Ejemplo n.º 1
0
        private async Task ProtocolPeformanceTestAsync()
        {
            Console.WriteLine("Setting up for ProtocolPeformanceTestAsync ...");
            Cancel   = new CancellationTokenSource();
            Testdata = TestDataFactory.CreateCrazyNesting();

            foreach (var layered in Enum.GetValues(typeof(LayeredChoice)))
            {
                Layered = (LayeredChoice)layered;
                await RunTestAsync(async (bool b) => { return(await GenericProtocolFactory <TBinaryProtocol>(b)); });
                await RunTestAsync(async (bool b) => { return(await GenericProtocolFactory <TCompactProtocol>(b)); });
                await RunTestAsync(async (bool b) => { return(await GenericProtocolFactory <TJsonProtocol>(b)); });
            }
        }
Ejemplo n.º 2
0
            private readonly TConfiguration Configuration = null;  // or new TConfiguration() if needed

            internal void Parse(List <string> args)
            {
                for (var i = 0; i < args.Count; ++i)
                {
                    if (args[i] == "-u")
                    {
                        url       = args[++i];
                        transport = TransportChoice.Http;
                    }
                    else if (args[i] == "-n")
                    {
                        numIterations = Convert.ToInt32(args[++i]);
                    }
                    else if (args[i].StartsWith("--pipe="))
                    {
                        pipe      = args[i].Substring(args[i].IndexOf("=") + 1);
                        transport = TransportChoice.NamedPipe;
                    }
                    else if (args[i].StartsWith("--host="))
                    {
                        // check there for ipaddress
                        host = args[i].Substring(args[i].IndexOf("=") + 1);
                        if (transport != TransportChoice.TlsSocket)
                        {
                            transport = TransportChoice.Socket;
                        }
                    }
                    else if (args[i].StartsWith("--port="))
                    {
                        port = int.Parse(args[i].Substring(args[i].IndexOf("=") + 1));
                        if (transport != TransportChoice.TlsSocket)
                        {
                            transport = TransportChoice.Socket;
                        }
                    }
                    else if (args[i] == "-b" || args[i] == "--buffered" || args[i] == "--transport=buffered")
                    {
                        layered = LayeredChoice.Buffered;
                    }
                    else if (args[i] == "-f" || args[i] == "--framed" || args[i] == "--transport=framed")
                    {
                        layered = LayeredChoice.Framed;
                    }
                    else if (args[i] == "-t")
                    {
                        numThreads = Convert.ToInt32(args[++i]);
                    }
                    else if (args[i] == "--binary" || args[i] == "--protocol=binary")
                    {
                        protocol = ProtocolChoice.Binary;
                    }
                    else if (args[i] == "--compact" || args[i] == "--protocol=compact")
                    {
                        protocol = ProtocolChoice.Compact;
                    }
                    else if (args[i] == "--json" || args[i] == "--protocol=json")
                    {
                        protocol = ProtocolChoice.Json;
                    }
                    else if (args[i] == "--ssl")
                    {
                        transport = TransportChoice.TlsSocket;
                    }
                    else if (args[i] == "--help")
                    {
                        PrintOptionsHelp();
                        return;
                    }
                    else
                    {
                        Console.WriteLine("Invalid argument: {0}", args[i]);
                        PrintOptionsHelp();
                        return;
                    }
                }

                switch (transport)
                {
                case TransportChoice.Socket:
                    Console.WriteLine("Using socket transport");
                    break;

                case TransportChoice.TlsSocket:
                    Console.WriteLine("Using encrypted transport");
                    break;

                case TransportChoice.Http:
                    Console.WriteLine("Using HTTP transport");
                    break;

                case TransportChoice.NamedPipe:
                    Console.WriteLine("Using named pipes transport");
                    break;

                default:      // unhandled case
                    Debug.Assert(false);
                    break;
                }

                switch (layered)
                {
                case LayeredChoice.Framed:
                    Console.WriteLine("Using framed transport");
                    break;

                case LayeredChoice.Buffered:
                    Console.WriteLine("Using buffered transport");
                    break;

                default:      // unhandled case?
                    Debug.Assert(layered == LayeredChoice.None);
                    break;
                }

                switch (protocol)
                {
                case ProtocolChoice.Binary:
                    Console.WriteLine("Using binary protocol");
                    break;

                case ProtocolChoice.Compact:
                    Console.WriteLine("Using compact protocol");
                    break;

                case ProtocolChoice.Json:
                    Console.WriteLine("Using JSON protocol");
                    break;

                default:      // unhandled case?
                    Debug.Assert(false);
                    break;
                }
            }
Ejemplo n.º 3
0
 internal void Parse(List <string> args)
 {
     for (var i = 0; i < args.Count; i++)
     {
         if (args[i].StartsWith("--pipe="))
         {
             pipe      = args[i].Substring(args[i].IndexOf("=") + 1);
             transport = TransportChoice.NamedPipe;
         }
         else if (args[i].StartsWith("--port="))
         {
             port = int.Parse(args[i].Substring(args[i].IndexOf("=") + 1));
             if (transport != TransportChoice.TlsSocket)
             {
                 transport = TransportChoice.Socket;
             }
         }
         else if (args[i] == "-b" || args[i] == "--buffered" || args[i] == "--transport=buffered")
         {
             layered = LayeredChoice.Buffered;
         }
         else if (args[i] == "-f" || args[i] == "--framed" || args[i] == "--transport=framed")
         {
             layered = LayeredChoice.Framed;
         }
         else if (args[i] == "--binary" || args[i] == "--protocol=binary")
         {
             protocol = ProtocolChoice.Binary;
         }
         else if (args[i] == "--compact" || args[i] == "--protocol=compact")
         {
             protocol = ProtocolChoice.Compact;
         }
         else if (args[i] == "--json" || args[i] == "--protocol=json")
         {
             protocol = ProtocolChoice.Json;
         }
         else if (args[i] == "--threaded" || args[i] == "--server-type=threaded")
         {
             throw new NotImplementedException(args[i]);
         }
         else if (args[i] == "--threadpool" || args[i] == "--server-type=threadpool")
         {
             throw new NotImplementedException(args[i]);
         }
         else if (args[i] == "--prototype" || args[i] == "--processor=prototype")
         {
             throw new NotImplementedException(args[i]);
         }
         else if (args[i] == "--ssl")
         {
             transport = TransportChoice.TlsSocket;
         }
         else if (args[i] == "--help")
         {
             PrintOptionsHelp();
             return;
         }
         else
         {
             Console.WriteLine("Invalid argument: {0}", args[i]);
             PrintOptionsHelp();
             return;
         }
     }
 }