Esempio n. 1
0
        /// <summary>
        /// 测试
        /// </summary>
        private static void test()
        {
            int left = Client.Left;

            AutoCSer.TestCase.TcpInternalStreamServerPerformance.IStreamServer client = AutoCSer.Net.TcpInternalStreamServer.Emit.Client <AutoCSer.TestCase.TcpInternalStreamServerPerformance.IStreamServer> .Create();

            using (AutoCSer.Net.TcpInternalStreamServer.Emit.MethodClient methodClient = client as AutoCSer.Net.TcpInternalStreamServer.Emit.MethodClient)
            {
                Client.SendCount = Client.ReceiveCount = 0;
                tcpClient        = methodClient._TcpClient_;

                Client.Start(ClientTestType.Synchronous, Client.Count / 10);
                int threadCount = 64;
                for (int count = Client.ThreadCount = threadCount, right = Client.Count / 10 / threadCount; count != 0; --count)
                {
                    AutoCSer.Threading.ThreadPool.TinyBackground.Start(new ClientSynchronous {
                        Client = client, Left = left, Right = right
                    }.Run);
                }
                Console.WriteLine("thread " + threadCount.toString() + " end " + Client.Time.ElapsedMilliseconds.toString() + "ms");
                wait();
                sleep();

                Client.Start(ClientTestType.Synchronous, Client.Count / 100);
                for (int right = Client.Count / 100; right != 0;)
                {
                    if (client.Add(left, --right).Value != left + right)
                    {
                        ++Client.ErrorCount;
                    }
                }
                Client.Time.Stop();
                Client.WaitHandle.Set();
                Console.WriteLine("thread 1 end " + Client.Time.ElapsedMilliseconds.toString() + "ms");
                wait();
                sleep();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 远程表达式测试
        /// </summary>
        /// <returns></returns>
        internal static bool TestCase()
        {
            using (AutoCSer.Net.TcpInternalStreamServer.Server server = AutoCSer.Net.TcpInternalStreamServer.Emit.Server <IRefOut> .Create(new RefOut()))
            {
                if (server.IsListen)
                {
                    using (AutoCSer.Net.TcpInternalStreamServer.Emit.MethodClient client = AutoCSer.Net.TcpInternalStreamServer.Emit.Client <IRefOut> .Create() as AutoCSer.Net.TcpInternalStreamServer.Emit.MethodClient)
                    {
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticField).Value.Value != 1)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticProperty).Value.Value != 2)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticMethod(3)).Value.Value != 3)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticField.Value).Value != 1)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticProperty.Value).Value != 2)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticMethod(3).Value).Value != 3)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticMethod(4)[3]).Value != 4 + 3)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticMethod(4).GetNextNode(2)).Value.Value != 4 + 2)
                        {
                            return(false);
                        }

                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticField.NextNode).Value.Value != 1 + 1)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticProperty.NextNode).Value.Value != 2 + 1)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticMethod(3).NextNode).Value.Value != 3 + 1)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticField.NextNode.Value).Value != 1 + 1)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticProperty.NextNode.Value).Value != 2 + 1)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticMethod(3).NextNode.Value).Value != 3 + 1)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticMethod(4).NextNode[3]).Value != 4 + 1 - 3)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticMethod(4).NextNode.GetLastNode(2)).Value.Value != 4 + 1 - 2)
                        {
                            return(false);
                        }

                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticField.NextNode.LastNode).Value.Value != 1)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticProperty.NextNode.LastNode).Value.Value != 2)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticMethod(3).NextNode.LastNode).Value.Value != 3)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticField.NextNode.LastNode.Value).Value != 1)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticProperty.NextNode.LastNode.Value).Value != 2)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticMethod(3).NextNode.LastNode.Value).Value != 3)
                        {
                            return(false);
                        }

                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticField.NextNode.LastNode.NextNode).Value.Value != 1 + 1)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticProperty.NextNode.LastNode.NextNode).Value.Value != 2 + 1)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticMethod(3).NextNode.LastNode.NextNode).Value.Value != 3 + 1)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticField.NextNode.LastNode.NextNode.Value).Value != 1 + 1)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticProperty.NextNode.LastNode.NextNode.Value).Value != 2 + 1)
                        {
                            return(false);
                        }
                        if (client._TcpClient_.GetRemoteExpression(RemoteExpression.StaticMethod(3).NextNode.LastNode.NextNode.Value).Value != 3 + 1)
                        {
                            return(false);
                        }

                        return(true);
                    }
                }
            }
            return(false);
        }