From: Luke M. <lu...@us...> - 2005-08-12 02:30:07
|
Update of /cvsroot/ipbench/ipbench2/src/tests/nfs_latency In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7638/src/tests/nfs_latency Modified Files: nfs_latency.c Log Message: Move toward marshalling implementation Index: nfs_latency.c =================================================================== RCS file: /cvsroot/ipbench/ipbench2/src/tests/nfs_latency/nfs_latency.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** nfs_latency.c 4 Aug 2005 05:09:03 -0000 1.5 --- nfs_latency.c 12 Aug 2005 02:29:58 -0000 1.6 *************** *** 7,10 **** --- 7,30 ---- */ + static struct result{ + uint64_t microseconds; + uint64_t sends; + uint64_t recvs; + uint64_t rtt_av; + uint64_t rtt_min; + uint64_t rtt_max; + uint64_t rtt_std; + uint64_t rtt_med; + } result; + + /* We marshall the result up into this structure */ + struct marshalled_result { + uint64_t time; + uint64_t samples; + uint64_t sends; + uint64_t recvs; + uint64_t data[]; + }; + /* * Setup your test. After this is complete you should be ready to *************** *** 16,24 **** { int x; dbprintf("nfs_latency_setup - %s - %d - %s\n", hostname, port, arg); ! x = init_and_open("192.168.0.1", "/tmp", "bench.file"); assert(x==0); return 0; } --- 36,74 ---- { int x; + char *tmp, *path, *filename; + dbprintf("nfs_latency_setup - %s - %d - %s\n", hostname, port, arg); ! /* hostname is the machine you want to hit with nfs traffic. ! * port you can ignore. ! * arg is just a string that you need to parse however you want ! */ ! ! tmp = strdup(arg); ! path = filename = tmp; ! while(*tmp!='\0'){ ! if(*tmp=='/') ! filename=tmp; ! tmp++; ! } ! ! if(filename==path){ ! /* no / found, just a filename */ ! path="/"; ! }else{ ! /* split the filename and path */ ! *filename='\0'; ! filename++; ! } ! ! assert(*path!='\0' && *filename!='\0'); ! ! dbprintf("nfs_latency_setup - path=%s filename=%s\n", path, filename); ! ! x = init_and_open(hostname, path, filename); assert(x==0); + free(tmp); + return 0; } *************** *** 31,34 **** --- 81,85 ---- } + uint64_t samples; uint64_t* sample; int nfs_latency_finished = 0; *************** *** 46,49 **** --- 97,102 ---- int r; uint64_t now, then; + uint64_t start_time, end_time; + uint64_t requests, replies; dbprintf("NFS_LATENCY START\n"); *************** *** 53,56 **** --- 106,110 ---- if(nfs_latency_finished==0){ /* allocate memory for samples */ + samples = target; sample = malloc(sizeof(uint64_t) * target); }else{ *************** *** 59,66 **** --- 113,125 ---- } + start_time = time_stamp(); + requests = replies = 0; + while(i<target){ now = time_stamp(); r = generate_request(now); + requests++; if(process_reply(&then)==0){ + replies++; sample[i] = now - then; dbprintf("delta = %ld\n", sample[i]); *************** *** 69,74 **** --- 128,140 ---- } + end_time = time_stamp(); + + result.microseconds = tick_to_usec(start_time - end_time); + result.sends = requests; + result.recvs = replies; + nfs_latency_finished = 1; dbprintf("NFS latency test complete.\n"); + return 0; } *************** *** 100,119 **** nfs_latency_marshall (char **data, int * size, double running_time) { ! char *ok_string = "nfs_latency succeeded\n"; ! char *not_ok_string = "nfs_latency failed\n"; ! dbprintf("NFS_LATENCY MARSHALL\n"); ! if(nfs_latency_finished==1){ ! dbprintf("test was finished\n"); ! *data = ok_string; ! *size = strlen(*data) + 1; ! return 0; } ! /* else */ ! dbprintf("test was not finished\n"); ! *data = not_ok_string; ! *size = strlen(*data) + 1; ! return 1; } --- 166,199 ---- nfs_latency_marshall (char **data, int * size, double running_time) { ! uint64_t i; ! struct marshalled_result *tosend; ! dbprintf("nfs_latency marshall arguments.\n"); ! tosend = malloc(sizeof(struct marshalled_result) + ! sizeof(uint64_t) * samples); ! ! if (tosend == NULL){ ! dbprintf("Can't malloc %d bytes\n", ! sizeof(struct marshalled_result) + ! sizeof(uint64_t) * samples); ! return -1; } ! ! ! for(i=0; i<samples; i++){ ! /* XXX is sample[i] in uS? */ ! tosend->data[i] = htonll(tick_to_usec(sample[i])); ! } ! ! tosend->time = htonll(result.microseconds); ! tosend->samples = htonll(samples); ! tosend->sends = htonll(result.sends); ! tosend->recvs = htonll(result.recvs); ! ! *data = (char*)tosend; ! *size = sizeof(struct marshalled_result) + (sizeof(uint64_t)*samples); ! ! return 0; } *************** *** 125,129 **** nfs_latency_marshall_cleanup(char **data) { ! dbprintf("NFS_LATENCY CLEANUP MARSHALL\n"); } --- 205,209 ---- nfs_latency_marshall_cleanup(char **data) { ! free(*data); } *************** *** 143,152 **** int *data_len) { ! char *buf = malloc (input_len); ! dbprintf("[unmarshall] start\n"); ! *data = buf; ! memcpy(buf, input, input_len); ! *data_len = input_len; ! dbprintf("[unmarshall] end\n"); return 0; } --- 223,249 ---- int *data_len) { ! uint64_t i; ! struct marshalled_result *theresult; ! ! theresult = (struct marshalled_result *)(input); ! theresult->time = ntohll(theresult->time); ! theresult->samples = ntohll(theresult->samples); ! theresult->sends = ntohll(theresult->sends); ! theresult->recvs = ntohll(theresult->recvs); ! ! for(i=0; i<theresult->samples; i++){ ! theresult->data[i] = ntohll(theresult->data[i]); ! } ! ! *data_len = sizeof(struct marshalled_result) + ! (sizeof(uint64_t) * theresult->samples); ! *data = malloc(*data_len); ! if (*data == NULL){ ! dbprintf("Out of buffer space.\n"); ! return -1; ! } ! ! memcpy(*data, input, input_len); ! return 0; } *************** *** 174,187 **** nfs_latency_output(struct client_data data[], int nelem) { ! int i, ret = 0; dbprintf("NFS_LATENCY OUTPUT (nelem %d)\n", nelem); for (i = 0; i < nelem; i++) { ! if (!data[i].valid) { ! dbprintf("We got some invalid data! Trying again\n"); ! ret = 1; ! } ! printf ("NFS_LATENCY RETURNED: %s\n", (char*)data[i].data); } dbprintf ("NFS_LATENCY DONE\n"); ! return ret; } --- 271,285 ---- nfs_latency_output(struct client_data data[], int nelem) { ! int i; dbprintf("NFS_LATENCY OUTPUT (nelem %d)\n", nelem); for (i = 0; i < nelem; i++) { ! struct marshalled_result *theresult; ! theresult = (struct marshalled_result*)&data[i].data; ! printf("load generator %ld...\n", i); ! printf("time=%ld\n", theresult->time); ! printf("requests=%ld\n", theresult->sends); ! printf("reples=%ld\n", theresult->recvs); } dbprintf ("NFS_LATENCY DONE\n"); ! return 0; } |