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