/// <summary> /// 测试 /// </summary> private static void test() { int left = TcpInternalStreamClientPerformance.Client.Left; AutoCSer.TestCase.TcpStreamServerPerformance.IOpenStreamServer client = AutoCSer.Net.TcpOpenStreamServer.Emit.Client <AutoCSer.TestCase.TcpStreamServerPerformance.IOpenStreamServer> .Create(); using (AutoCSer.Net.TcpOpenStreamServer.Emit.MethodClient methodClient = client as AutoCSer.Net.TcpOpenStreamServer.Emit.MethodClient) { tcpClient = methodClient._TcpClient_; TcpInternalStreamClientPerformance.Client.SendCount = TcpInternalStreamClientPerformance.Client.ReceiveCount = 0; TcpInternalStreamClientPerformance.Client.Start(TcpInternalStreamClientPerformance.ClientTestType.Synchronous, TcpInternalStreamClientPerformance.Client.Count / 10); int threadCount = 64; for (int count = TcpInternalStreamClientPerformance.Client.ThreadCount = threadCount, right = TcpInternalStreamClientPerformance.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 " + TcpInternalStreamClientPerformance.Client.Time.ElapsedMilliseconds.toString() + "ms"); wait(); sleep(); TcpInternalStreamClientPerformance.Client.Start(TcpInternalStreamClientPerformance.ClientTestType.Synchronous, TcpInternalStreamClientPerformance.Client.Count / 100); for (int right = TcpInternalStreamClientPerformance.Client.Count / 100; right != 0;) { if (client.Add(left, --right).Value != left + right) { ++TcpInternalStreamClientPerformance.Client.ErrorCount; } } TcpInternalStreamClientPerformance.Client.Time.Stop(); TcpInternalStreamClientPerformance.Client.WaitHandle.Set(); Console.WriteLine("thread 1 end " + TcpInternalStreamClientPerformance.Client.Time.ElapsedMilliseconds.toString() + "ms"); wait(); sleep(); } }
/// <summary> /// 远程表达式测试 /// </summary> /// <returns></returns> internal static bool TestCase() { using (AutoCSer.Net.TcpOpenStreamServer.Server server = AutoCSer.Net.TcpOpenStreamServer.Emit.Server <IRefOut> .Create(new RefOut())) { if (server.IsListen) { using (AutoCSer.Net.TcpOpenStreamServer.Emit.MethodClient client = AutoCSer.Net.TcpOpenStreamServer.Emit.Client <IRefOut> .Create() as AutoCSer.Net.TcpOpenStreamServer.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); }