[Mono-list] WCF via TCP is frightfully slow

mauzik mauzik at centrum.cz
Sat Sep 21 19:52:06 UTC 2013


Hi, I wrote simple benchmark for WCF and run both .NET and Mono. I am
terrified of results. Under .NET result is average 1198 ms, but in Mono is
53162 ms. Mono is about *44x* slower than .NET!! Anybody knows what is
wrong?

relevant code:
*main class:*

 IPersonService service = null;
            // 1000 requests to server
            int[] countOfRequest = { 1000/*,5000,10000,20000,30000*/ };
            // create simple log file
            StreamWriter swritter = new StreamWriter("output.txt",true);
            int pass = 1;
            //start TCP WCF server
            Server.CreateTcpServer();

            foreach (var request in countOfRequest)
            {
                
                for (int j = 1; j <= pass; j++)
                {
                    
                    service = Client.GetTcpService();

                    if (j == 1)
                        swritter.WriteLine(String.Format("Count of Request
{0}",request));

                    GC.Collect();
                    var interval = request;
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    List<Person> list = new List<Person>();
                    for (int i = 0; i < interval; i++)
                    {
                     list.Add(service.GetPerson());
                        Console.WriteLine(list[i]);
                    }
                    sw.Stop();

                    swritter.WriteLine(sw.ElapsedMilliseconds);

                    Console.WriteLine("pass no. {0}", j);
                }
            }
            swritter.Flush();
            swritter.Close();
            Server.Close();
            Console.WriteLine("done!");
            Console.ReadLine();

*Server*: 

 public static void CreateTcpServer()
        {
            var binding = new NetTcpBinding();
            host = new ServiceHost(typeof(PersonService), new
Uri("net.tcp://localhost:8090/PersonService"));

            host.AddServiceEndpoint(typeof(IPersonService), binding,
string.Empty);
            host.Open();

        }


*client*:

public static IPersonService GetNamedPipesService()
        {
            var myBinding = new NetNamedPipeBinding();
            var myEndpoint = new
EndpointAddress("net.pipe://localhost/PersonService");
            var myChannelFactory = new
ChannelFactory<IPersonService>(myBinding, myEndpoint);

            return myChannelFactory.CreateChannel();

        }

I'm glad for every answer



--
View this message in context: http://mono.1490590.n4.nabble.com/WCF-via-TCP-is-frightfully-slow-tp4660946.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list