C# 如何使XMLRPC.NET与perl速度相匹配? 我有C++编写的 XMLRPC服务器(使用 LIXMLRPC++ >。它提供了一个返回字符串的函数getversion()
从Perl调用它(使用),100调用1.25sC# 如何使XMLRPC.NET与perl速度相匹配? 我有C++编写的 XMLRPC服务器(使用 LIXMLRPC++ >。它提供了一个返回字符串的函数getversion(),c#,c++,perl,xml-rpc,C#,C++,Perl,Xml Rpc,从Perl调用它(使用),100调用1.25s 从C#(使用XMLRPC.NET)调用它,100调用50.322s 这是在Windows7 Pro上运行的 你知道发生了什么事,怎么解决吗 [XmlRpcUrl("http://localhost:9000/RPC2")] public interface ICutControl : IXmlRpcProxy { [XmlRpcMethod] string getversion(); } class Program { public
C#
(使用XMLRPC.NET
)调用它,100调用50.322s[XmlRpcUrl("http://localhost:9000/RPC2")]
public interface ICutControl : IXmlRpcProxy
{
[XmlRpcMethod]
string getversion();
}
class Program
{
public static void do_test()
{
ICutControl proxy;
proxy = XmlRpcProxyGen.Create<ICutControl>();
int count = 100;
try
{
for (int i = 0; i < 100; i++)
{
string version = proxy.getversion();
Console.WriteLine("{0}:{1}", i, version);
}
}
catch (System.Net.WebException ex)
{
Console.Error.WriteLine("exception: {0}", ex.Message);
}
}
proxy = null;
}
[XmlRpcUrl(“http://localhost:9000/RPC2")]
公共接口ICutControl:IXmlRpcProxy
{
[XmlRpcMethod]
字符串getversion();
}
班级计划
{
公共静态无效do_测试()
{
ICUT控制代理;
proxy=xmlrpcproxy.Create();
整数计数=100;
尝试
{
对于(int i=0;i<100;i++)
{
字符串版本=proxy.getversion();
WriteLine(“{0}:{1}”,i,版本);
}
}
捕获(System.Net.WebException-ex)
{
WriteLine(“异常:{0}”,例如Message);
}
}
proxy=null;
}
[更新]
我试过压缩,但没什么不同。由于这似乎是发生在客户端,没有重新启动服务器,我的想法。
我使用的perl是cygwin。我在下面添加了perl
#!/usr/bin/perl
use warnings;
use strict;
use RPC::XML;
use RPC::XML::Client;
my $url = 'http://localhost:9000/RPC2';
my $cli = RPC::XML::Client->new($url);
for (my $i = 0; $i < 100; $i++) {
my $resp = $cli->send_request('getversion', ());
print "version:", $resp->value, "\n";
}
#/usr/bin/perl
使用警告;
严格使用;
使用RPC::XML;
使用RPC::XML::Client;
我的$url=http://localhost:9000/RPC2';
my$cli=RPC::XML::Client->new($url);
对于(我的$i=0;$i<100;$i++){
my$resp=$cli->send_请求('getversion',());
打印“版本:”,$resp->value“\n”;
}
[更新]
我没有找到XMLRPC.NET速度较慢的原因的答案
但是通过在libxmlrpc++库周围编写一个C++/CLR包装器,我的速度确实提高了100倍以上。到目前为止,您尝试了什么?您确定在RPC调用中浪费了时间吗?它可能浪费在其他地方吗?我用WireShark查看客户请求。对于XMLRPC.NET,延迟发生在回复到达之后。