我有三个阵列需要组合在一个三维数组中.以下代码显示Performance Explorer中的性能降低.有更快的解决方案吗?
for (int i = 0; i < sortedIndex.Length; i++) {
if (i < num_in_left)
{
// add instance to the left child
leftnode[i, 0] = sortedIndex[i];
leftnode[i, 1] = sortedInstances[i];
leftnode[i, 2] = sortedLabels[i];
}
else
{
// add instance to the right child
rightnode[i-num_in_left, 0] = sortedIndex[i];
rightnode[i-num_in_left, 1] = sortedInstances[i];
rightnode[i-num_in_left, 2] = sortedLabels[i];
}
}
Run Code Online (Sandbox Code Playgroud)
更新:
我其实是在尝试做以下事情:
//given three 1d arrays
double[] sortedIndex, sortedInstances, sortedLabels;
// copy them over to a 3d array (forget about …Run Code Online (Sandbox Code Playgroud) 我在Node.js中为多用户人工智能应用程序构建了多个套接字服务器应用程序.我们正在考虑每盒1K到10K有源插座连接.然而,即使在空闲和0活动连接时,我的一些服务器在Unix上运行时消耗50-100 MB的内存.我确信使用像C#或C++这样合理的平台,这应该接近0 MB.所以我们正在考虑将端口变为"更好"的平台.现在让我澄清一下我的用例:
我们选择节点,因为它是Unix友好的(不像.NET),似乎很容易使用.但是由于目前的内存消耗,我们需要评估其他选项.许多人将Node.js与ASP.NET进行了比较,但我需要用C#或C++构建套接字服务器.
我在.NET和C++方面有丰富的经验.像SuperSocket(由Redgate和Telerik使用)这样的库可以处理.NET中的所有低级内容.我将不得不为C++找到一个类似的套接字框架.
总而言之,使用.NET或C++而不是Node.js有什么好处?考虑到我的服务器是高度CPU限制的(不受I/O约束)使用.NET/C++的好处是显着的还是我应该坚持使用Node.js?关于将Node.js应用程序移植到C#或C++的任何其他评论?
赏金:我需要C#和/或C++中的建议和推荐的套接字服务器库/实现/示例应用程序.必须是开源的.我需要它是高性能,异步和无错误.必须支持二进制数据传输.必须在Windows上运行.Unix是一个奖励.
我有服务器和客户端控制台应用程序,它们可以正常通信并发送一些字符串。这是代码...
服务器
public static void Main()
{
try
{
IPAddress ipAd = IPAddress.Parse("127.0.0.1");
/* Initializes the Listener */
TcpListener myList = new TcpListener(ipAd, 1234);
/* Start Listeneting at the specified port */
myList.Start();
Console.WriteLine("The server is running at port 8001...");
Console.WriteLine("The local End point is :" + myList.LocalEndpoint);
Console.WriteLine("Waiting for a connection.....");
Socket s = myList.AcceptSocket();
Console.WriteLine("Connection accepted from " + s.RemoteEndPoint);
byte[] b = new byte[100];
int k = s.Receive(b);
Console.WriteLine("Recieved...");
for (int i = 0; i < k; …Run Code Online (Sandbox Code Playgroud)