Листинг A.12. Клиент RPC для измерения полосы пропускания
//bench/bw_sunrpc_client.с
1 #include "unpipc.h"
2 #include "bw_sunrpc.h"
3 void *buf;
4 int totalnbytes, xfersize;
5 int
6 main(int argc, char **argv)
7 {
8 int i, nloop, ntowrite;
9 CLIENT *cl;
10 data_in in;
11 if (argc != 6)
12 err_quit("usage: bw_sunrpc_client
13 " <#mbytes> <#bytes/write>
14 nloop = atoi(argv[2]);
15 totalnbytes = atoi(argv[3]) * 1024 * 1024;
16 xfersize = atoi(argv[4]);
17 buf = Valloc(xfersize);
18 Touch(buf, xfersize);
19 cl = Clnt_create(argv[1], BW_SUNRPC_PROG, BW_SUNRPC_VERS, argv[5]);
20 Start_time();
21 for (i = 0; i < nloop; i++) {
22 ntowrite = totalnbytes;
23 while (ntowrite > 0) {
24 in.data.data_len = xfersize;
25 in.data.data_val = buf;
26 if (bw_sunrpc_1(&in, cl) == NULL)
27 err_quit("%s", clnt_sperror(cl, argv[1]));
28 ntowrite –= xfersize;
29 }
30 }
31 printf("bandwidth: %.3f MB/sec\n",
32 totalnbytes / Stop_time() * nloop);
33 exit(0);
34 }