From: Peter C. <pc...@us...> - 2010-02-10 00:55:55
|
Update of /cvsroot/ipbench/ipbench2/src/tests/nfs_latency In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv10959/src/tests/nfs_latency Modified Files: nfs_latency.c Log Message: Attempt to add warmup/cooldown to nfs_latency test. Index: nfs_latency.c =================================================================== RCS file: /cvsroot/ipbench/ipbench2/src/tests/nfs_latency/nfs_latency.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** nfs_latency.c 9 Feb 2010 00:24:16 -0000 1.15 --- nfs_latency.c 10 Feb 2010 00:55:34 -0000 1.16 *************** *** 32,35 **** --- 32,38 ---- char *filename; uint64_t rate; + uint64_t warmup; /* usec */ + uint64_t cooldown; /* usec */ + uint64_t samples; /* count */ } nfs_options; *************** *** 41,45 **** nfs_options.path = "/tmp"; nfs_options.filename = "bench.file"; ! nfs_options.rate = 10000; /* parse parameters */ --- 44,51 ---- nfs_options.path = "/tmp"; nfs_options.filename = "bench.file"; ! nfs_options.rate = 10000; /* per second */ ! nfs_options.cooldown = 0; ! nfs_options.warmup = 0; ! nfs_options.samples = 20000; /* parse parameters */ *************** *** 68,71 **** --- 74,91 ---- } + if (!strcmp(cmd, "warmup")) { + nfs_options.warmup = strtoll(val, (char**)NULL, 10) * US_PER_S; + continue; + } + if (!strcmp(cmd, "cooldown")) { + nfs_options.cooldown = strtoll(val, (char**)NULL, 10) * US_PER_S; + continue; + } + if (!strcmp(cmd, "samples")) { + nfs_options.samples = strtoll(val, (char**)NULL, 10) * US_PER_S; + continue; + } + + dbprintf("Invalid argument %s=%s.\n", cmd, val); } *************** *** 75,78 **** --- 95,102 ---- nfs_options.filename, nfs_options.rate); + dbprintf("parse_arg: using: warmup = %lld, cooldown = %lld, nsamples = %lld\n", + nfs_options.warmup, + nfs_options.cooldown, + nfs_options.samples); return 0; *************** *** 102,106 **** x = init_and_open(hostname, nfs_options.path, nfs_options.filename); - return x; --- 126,129 ---- *************** *** 127,142 **** { int i=0; ! int target=200000; int r; ! uint64_t now, then, delta; ! uint64_t start_time, end_time; uint64_t requests, replies; uint64_t predicted_requests; dbprintf("NFS_LATENCY START\n"); gettimeofday(start, NULL); ! dbprintf("NFS latency start,\n"); ! if(nfs_latency_finished==0){ /* allocate memory for samples */ samples = target; --- 150,167 ---- { int i=0; ! int target=nfs_options.samples; int r; ! uint64_t now, then, delta, cooldown; ! uint64_t start_time, warmup_time, cooldown_time, end_time; ! /* start_time < warmup_time < cooldown_time < end_time */ uint64_t requests, replies; uint64_t predicted_requests; + uint64_t offset; dbprintf("NFS_LATENCY START\n"); gettimeofday(start, NULL); ! dbprintf("NFS latency start warmup,\n"); ! if (nfs_latency_finished==0){ /* allocate memory for samples */ samples = target; *************** *** 148,179 **** start_time = time_stamp(); ! requests = replies = 0; - while(i<target){ - now = time_stamp(); - delta = tick_to_usec(now - start_time); predicted_requests = (delta * nfs_options.rate) / US_PER_S; ! ! if(predicted_requests > requests){ r = generate_request(now); ! if(r>0){ requests++; ! }else{ //dbprintf("generate request failed\n"); } } ! if(process_reply(&then)==0){ replies++; sample[i] = now - then; i++; } } end_time = time_stamp(); ! ! result.microseconds = tick_to_usec(end_time - start_time); ! result.sends = requests; result.recvs = replies; --- 173,211 ---- start_time = time_stamp(); ! offset = requests = replies = 0; ! warmup_time = start_time + usec_to_tick(nfs_options.warmup); ! cooldown_time = end_time = 0; /* calculated later */ ! cooldown = usec_to_tick(nfs_options.cooldown); ! ! while ((now = time_stamp()) && (end_time == 0 || now < end_time)) { delta = tick_to_usec(now - start_time); predicted_requests = (delta * nfs_options.rate) / US_PER_S; ! if (predicted_requests > requests){ r = generate_request(now); ! if (r > 0){ requests++; ! } else { //dbprintf("generate request failed\n"); } } ! if (process_reply(&then) == 0 && now > warmup_time && cooldown_time == 0){ ! if (offset == 0) ! offset = requests; replies++; sample[i] = now - then; i++; } + + if (replies >= target) { + cooldown_time = now; + result.sends = requests - offset; + end_time = cooldown_time + cooldown; + } } end_time = time_stamp(); ! result.microseconds = tick_to_usec(cooldown_time - warmup_time); result.recvs = replies; *************** *** 225,230 **** } ! for(i=0; i<samples; i++){ ! /* XXX is sample[i] in uS? */ tosend->data[i] = htonll(tick_to_usec(sample[i])); } --- 257,261 ---- } ! for (i = 0; i < samples; i++){ tosend->data[i] = htonll(tick_to_usec(sample[i])); } *************** *** 282,286 **** #endif ! for(i=0; i<theresult->samples; i++){ theresult->data[i] = ntohll(theresult->data[i]); } --- 313,317 ---- #endif ! for (i = 0; i < theresult->samples; i++){ theresult->data[i] = ntohll(theresult->data[i]); } *************** *** 294,298 **** } ! assert(input_len==*data_len); memcpy(*data, input, input_len); --- 325,329 ---- } ! assert(input_len == *data_len); memcpy(*data, input, input_len); *************** *** 336,340 **** total = 0; ! for(i=0; i<n; i++){ new_total = total + x[i]; assert(new_total >= total); --- 367,371 ---- total = 0; ! for (i = 0; i < n; i++){ new_total = total + x[i]; assert(new_total >= total); |