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

            AutoCSer.TestCase.TcpServerPerformance.IOpenSimpleServer client = AutoCSer.Net.TcpOpenSimpleServer.Emit.Client <AutoCSer.TestCase.TcpServerPerformance.IOpenSimpleServer> .Create();

            using (AutoCSer.Net.TcpOpenSimpleServer.Emit.MethodClient methodClient = client as AutoCSer.Net.TcpOpenSimpleServer.Emit.MethodClient)
            {
                TcpInternalSimpleClientPerformance.Client.Start(TcpInternalSimpleClientPerformance.TestType.Synchronous, TcpInternalSimpleClientPerformance.Client.Count);
                for (int right = TcpInternalSimpleClientPerformance.Client.Count; right != 0;)
                {
                    if (client.Add(left, --right).Value != left + right)
                    {
                        ++TcpInternalSimpleClientPerformance.Client.ErrorCount;
                    }
                }
                stop();
            }
            for (int threadCount = 2; threadCount <= 32; threadCount <<= 1)
            {
                TcpInternalSimpleClientPerformance.Client.ThreadCount = threadCount;
                TcpInternalSimpleClientPerformance.Client.Start(TcpInternalSimpleClientPerformance.TestType.Multithreading, TcpInternalSimpleClientPerformance.Client.Count * threadCount);
                for (int count = threadCount; count != 0; --count)
                {
                    AutoCSer.Threading.ThreadPool.TinyBackground.Start(new ClientThread {
                        Left = left, Right = TcpInternalSimpleClientPerformance.Client.Count
                    }.Run);
                }
                Console.WriteLine("thread start " + threadCount.toString() + " end " + TcpInternalSimpleClientPerformance.Client.Time.ElapsedMilliseconds.toString() + "ms");
                wait();
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        internal void Run()
        {
            AutoCSer.TestCase.TcpServerPerformance.IOpenSimpleServer client = AutoCSer.Net.TcpOpenSimpleServer.Emit.Client <AutoCSer.TestCase.TcpServerPerformance.IOpenSimpleServer> .Create();

            using (AutoCSer.Net.TcpOpenSimpleServer.Emit.MethodClient methodClient = client as AutoCSer.Net.TcpOpenSimpleServer.Emit.MethodClient)
            {
                int errorCount = 0;
                for (int left = Left, right = Right; right != 0;)
                {
                    if (client.Add(left, --right).Value != left + right)
                    {
                        ++errorCount;
                    }
                }
                Interlocked.Add(ref TcpInternalSimpleClientPerformance.Client.ErrorCount, errorCount);
                if (Interlocked.Decrement(ref TcpInternalSimpleClientPerformance.Client.ThreadCount) == 0)
                {
                    TcpInternalSimpleClientPerformance.Client.Time.Stop();
                    TcpInternalSimpleClientPerformance.Client.WaitHandle.Set();
                }
            }
        }
Example #3
0
        /// <summary>
        /// 远程表达式测试
        /// </summary>
        /// <returns></returns>
        internal static bool TestCase()
        {
            using (AutoCSer.Net.TcpOpenSimpleServer.Server server = AutoCSer.Net.TcpOpenSimpleServer.Emit.Server <IRefOut> .Create(new RefOut()))
            {
                if (server.IsListen)
                {
                    using (AutoCSer.Net.TcpOpenSimpleServer.Emit.MethodClient client = AutoCSer.Net.TcpOpenSimpleServer.Emit.Client <IRefOut> .Create() as AutoCSer.Net.TcpOpenSimpleServer.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);
        }