/// <summary> /// 测试 /// </summary> private static void test() { int left = Client.Left; AutoCSer.TestCase.TcpInternalSimpleServerPerformance.ISimpleServer client = AutoCSer.Net.TcpInternalSimpleServer.Emit.Client <AutoCSer.TestCase.TcpInternalSimpleServerPerformance.ISimpleServer> .Create(); using (AutoCSer.Net.TcpInternalSimpleServer.Emit.MethodClient methodClient = client as AutoCSer.Net.TcpInternalSimpleServer.Emit.MethodClient) { Client.Start(TestType.Synchronous, Client.Count); for (int right = Client.Count; right != 0;) { if (client.Add(left, --right).Value != left + right) { ++Client.ErrorCount; } } stop(); } for (int threadCount = 2; threadCount <= 32; threadCount <<= 1) { Client.ThreadCount = threadCount; Client.Start(TestType.Multithreading, Client.Count * threadCount); for (int count = threadCount; count != 0; --count) { AutoCSer.Threading.ThreadPool.TinyBackground.Start(new ClientThread { Left = left, Right = Client.Count }.Run); } Console.WriteLine("thread start " + threadCount.toString() + " end " + Client.Time.ElapsedMilliseconds.toString() + "ms"); wait(); } }
/// <summary> /// /// </summary> internal void Run() { AutoCSer.TestCase.TcpInternalSimpleServerPerformance.ISimpleServer client = AutoCSer.Net.TcpInternalSimpleServer.Emit.Client <AutoCSer.TestCase.TcpInternalSimpleServerPerformance.ISimpleServer> .Create(); using (AutoCSer.Net.TcpInternalSimpleServer.Emit.MethodClient methodClient = client as AutoCSer.Net.TcpInternalSimpleServer.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(); } } }
/// <summary> /// 远程表达式测试 /// </summary> /// <returns></returns> internal static bool TestCase() { using (AutoCSer.Net.TcpInternalSimpleServer.Server server = AutoCSer.Net.TcpInternalSimpleServer.Emit.Server <IRefOut> .Create(new RefOut())) { if (server.IsListen) { using (AutoCSer.Net.TcpInternalSimpleServer.Emit.MethodClient client = AutoCSer.Net.TcpInternalSimpleServer.Emit.Client <IRefOut> .Create() as AutoCSer.Net.TcpInternalSimpleServer.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); }