0
A
回答
0
这里我做什么:
#include <rpc/rpc.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/times.h>
#include <fcntl.h>
#include <time.h>
int main(int argc, char *argv[]) {
enum clnt_stat status;
CLIENT *handle;
struct timeval t;
clock_t rtime;
struct tms dumm;
int count = 100000;
int i;
time_t now;
char stamp[27];
int programm;
int version;
if (argc != 4) {
printf("Usage: rpcping <host> <program> <version>\n");
exit(1);
}
/*
* Create Client Handle
*/
programm = atoi(argv[2]);
version = atoi(argv[3]);
handle = clnt_create(argv[1], programm, version, "tcp");
if (handle == NULL) {
printf("clnt failed\n");
exit(1);
}
/*
* use 30 seconds timeout
*/
t.tv_sec = 30;
t.tv_usec = 0;
while (1) {
rtime = times(&dumm);
for (i = 0; i < count; i++) {
status = clnt_call(handle, 0, (xdrproc_t) xdr_void,
NULL, (xdrproc_t) xdr_void, NULL, t);
if (status == RPC_SUCCESS) { /* NOP */ }
}
now = time(NULL);
ctime_r(&now, stamp);
stamp[strlen(stamp) - 1] = '\0';
fprintf(stdout, "[%s]: Speed: %2.4fs.\n", stamp,
count/((double) (times(&dumm) - rtime)/(double) sysconf(_SC_CLK_TCK)));
fflush(stdout);
}
clnt_destroy(handle);
}
我有一个多线程版本,以及
https://gist.github.com/2401404
蒂格兰。
相关问题
- 1. Scapy:用scapy计算往返时间(RTT)
- 2. 计算平均往返时间?
- 3. 计算往返时间在Java中有一个IP地址,ping命令
- 4. 使用Ping ICMP消息定义往返时间
- 5. 使用Google地图来计算“往返”
- 6. 在C#中的往返日期计算#
- 7. 计算平均往返时间(AMQP/RabbitMQ的)
- 8. (sun)RPC auth_unix
- 9. 使用C计算时间段C
- 10. 计算往年
- 11. 计算真实网络往返
- 12. 计算过去在C#日期时间
- 13. 使用时间或时间计时两种算法(python)
- 14. 如何计算过程时间段
- 15. 计算ping网站时的响应时间(Ruby)
- 16. 使用时间戳计算时间
- 17. 计算经过时间
- 18. 计算时间差c天#
- 19. C - 测量计算时间
- 20. 计算C中的时间
- 21. C++/Qt - 计算时间
- 22. 日期时间计算C#
- 23. 计算前往国际国家的时间
- 24. 计算或存储空间数据
- 25. 用C计算经过时间的夏令时问题#
- 26. 多线程程序在C:计算线程堆栈空间
- 27. 理论上估计网络往返时间
- 28. 不能往返日期时间格式
- 29. 日期时间 - 字符串往返
- 30. 如何提高往返时间做TDD
http://mattgemmell.com/2008/12/08/what-have-you-tried/ – 2012-04-13 05:24:49
Joachim嗨。感谢您尝试提供帮助,即使是以粗鲁的方式。下面是我在问这个问题的时候做了一个新手(我仍然是一个新手):我用标题关键字的每种可能的组合搜索了网页(关键字是:SUN + RPC + ONC + RTT +往返+往返时间+ ping + null程序+ c +估计+客户端+服务器)。我阅读了关于RPC的每个文档。我甚至读过一些RFC标准表。 (我记得他们在想我。)我没有想出任何东西。所以下面的答案是我能找到的唯一解决方案。那是... – duru 2012-07-29 21:57:02
...为什么它很珍贵。无论如何,谢谢你的宝贵但粗鲁的贡献。 – duru 2012-07-29 21:57:21