|
From: Peter C. <pc...@us...> - 2010-03-12 03:04:00
|
Update of /cvsroot/ipbench/ipbench2/src/tests/nfs_latency In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv16353 Modified Files: nfs_glue.c nfs_latency.c Log Message: added standard deviation, and absulte deviation from median stats Index: nfs_latency.c =================================================================== RCS file: /cvsroot/ipbench/ipbench2/src/tests/nfs_latency/nfs_latency.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** nfs_latency.c 10 Feb 2010 03:56:28 -0000 1.19 --- nfs_latency.c 12 Mar 2010 03:03:46 -0000 1.20 *************** *** 2,5 **** --- 2,6 ---- #include "nfs_latency.h" #include "nfs_glue.h" + #include <math.h> /* *************** *** 42,47 **** /* set up default values */ ! nfs_options.path = "/tmp"; ! nfs_options.filename = "bench.file"; nfs_options.rate = 10000; /* per second */ nfs_options.cooldown = 0; --- 43,48 ---- /* set up default values */ ! nfs_options.path = strdup("/tmp/%h"); ! nfs_options.filename = strdup("bench.file"); nfs_options.rate = 10000; /* per second */ nfs_options.cooldown = 0; *************** *** 49,58 **** nfs_options.samples = 20000; /* parse parameters */ ! while (next_token(&arg, cmd, " \t,")){ if ((p = strchr(cmd, '='))) { *p = '\0'; val = p+1; ! }else{ val = NULL; } --- 50,60 ---- nfs_options.samples = 20000; + dbprintf("parse_arg(%s)\n", arg); /* parse parameters */ ! while (arg && next_token(&arg, cmd, " \t,")){ if ((p = strchr(cmd, '='))) { *p = '\0'; val = p+1; ! } else { val = NULL; } *************** *** 62,69 **** --- 64,73 ---- if (!strcmp(cmd, "path")){ + free(nfs_options.path); nfs_options.path = strdup(val); continue; } if (!strcmp(cmd, "filename")){ + free(nfs_options.filename); nfs_options.filename = strdup(val); continue; *************** *** 91,94 **** --- 95,124 ---- } + + dbprintf("Scanning path %s for %%h\n", nfs_options.path); + if ((p = strchr(nfs_options.path, '%'))) { + if (*++p == 'h') { + char name[200]; + *p='s'; + gethostname(name, sizeof name); + snprintf(cmd, sizeof cmd, nfs_options.path, name); + dbprintf("Expanded to %s\n", cmd); + free(nfs_options.path); + nfs_options.path = strdup(cmd); + } + } + dbprintf("Scanning path %s for %%h\n", nfs_options.filename); + if ((p = strchr(nfs_options.filename, '%'))) { + if (*++p == 'h') { + char name[200]; + dbprintf("Found %%h at %d\n", p-nfs_options.filename); + *p='s'; + gethostname(name, sizeof name); + snprintf(cmd, sizeof cmd, nfs_options.filename, name); + free(nfs_options.filename); + nfs_options.filename = strdup(cmd); + } + } + dbprintf("parse_arg: using: path=%s,filename=%s,rate=%lld\n", nfs_options.path, *************** *** 121,127 **** /* configure nfs options */ ! if (strlen(arg) != 0) ! if (parse_arg(arg)) ! return -1; x = init_and_open(hostname, nfs_options.path, nfs_options.filename); --- 151,159 ---- /* configure nfs options */ ! dbprintf("Calling parse_arg(%s)\n", arg); ! if (parse_arg(arg)) { ! dbprintf("parse_arg returned non-zero\n"); ! return -1; ! } x = init_and_open(hostname, nfs_options.path, nfs_options.filename); *************** *** 350,362 **** static int compare_uint64(const void *a, const void *b){ ! uint64_t *x, *y; ! x = (uint64_t*)a; ! y = (uint64_t*)b; ! if(*x < *y) return -1; ! if(*x > *y) return 1; --- 382,394 ---- static int compare_uint64(const void *a, const void *b){ ! uint64_t x, y; ! x = *(uint64_t *)a; ! y = *(uint64_t *)b; ! if (x < y) return -1; ! if (x > y) return 1; *************** *** 365,384 **** static uint64_t ! average_uint64(uint64_t *x, uint64_t n){ ! uint64_t i, total, new_total; ! assert(n>0); total = 0; ! for (i = 0; i < n; i++){ new_total = total + x[i]; assert(new_total >= total); total = new_total; } return (total / n); } /* * data[] is an array that has whatever was passed back from each --- 397,436 ---- static uint64_t ! average_uint64(uint64_t *x, unsigned n, double *stddevp){ ! double sumsqr; ! uint64_t total, new_total; ! unsigned i; ! double stddev; ! assert(n>1); total = 0; ! sumsqr = 0.0; for (i = 0; i < n; i++){ + /* guard against overflow */ new_total = total + x[i]; + sumsqr += x[i] * x[i]; assert(new_total >= total); total = new_total; } + stddev = sqrt((sumsqr - (double)(total*total)/n)/(n-1)); + *stddevp = stddev; return (total / n); } + static double + absolute_deviation_uint64(uint64_t samples, unsigned n, uint64_t median) + { + unsigned i; + int64_t d; + double deviation; + for (i = 0; i < n; i++) { + d = *samples++ - median; + deviation += d > 0 ? d : -d; + } + return d / n; + } + /* * data[] is an array that has whatever was passed back from each *************** *** 398,401 **** --- 450,454 ---- uint64_t avg_latency, avg_runtime; uint64_t tot_requests=0, tot_replies=0; + double stddevR, stddevL; dbprintf("NFS_LATENCY OUTPUT (nelem %d)\n", nelem); *************** *** 409,413 **** --- 462,468 ---- printf("Min latency,"); printf("Average latency,"); + printf("Stddeviation,"); printf("Median latency,"); + printf("Average abs. deviation,"); printf("Max latency,"); printf("Samples,"); *************** *** 415,418 **** --- 470,474 ---- printf("Average runtime,"); printf("Median runtime,"); + printf("Std dev runtime,"); printf("Max runtime"); printf("\n"); *************** *** 456,476 **** } - /* sort the runtimes */ - qsort(runtime, nelem, sizeof(uint64_t), compare_uint64); - avg_runtime = average_uint64(runtime, nelem); /* sort the samples */ qsort(aggregate, aggregate_count, sizeof(uint64_t), compare_uint64); ! avg_latency = average_uint64(aggregate, aggregate_count); printf("%" PRIu64 ",", (tot_requests*1000000) / avg_runtime); printf("%" PRIu64 ",", (tot_replies*1000000) / avg_runtime); printf("%" PRIu64 ",", aggregate[0]); printf("%" PRIu64 ",", avg_latency); printf("%" PRIu64 ",", aggregate[aggregate_count/2]); printf("%" PRIu64 ",", aggregate[aggregate_count-1]); printf("%" PRIu64 ",", aggregate_count); printf("%" PRIu64 ",", runtime[0]); printf("%" PRIu64 ",", avg_runtime); printf("%" PRIu64 ",", runtime[nelem/2]); printf("%" PRIu64, runtime[nelem-1]); --- 512,551 ---- } /* sort the samples */ + qsort(aggregate, aggregate_count, sizeof(uint64_t), compare_uint64); ! /* Discard 0-length samples */ ! for (i = 0; i < aggregate_count && aggregate[i] == 0; i++) ! ; ! ! aggregate += i; ! aggregate_count -= i; ! avg_latency = average_uint64(aggregate, aggregate_count, &stddevL); ! ! /* sort the runtimes */ ! qsort(runtime, nelem, sizeof(uint64_t), compare_uint64); ! /* Discard 0-length samples */ ! for (i = 0; i < nelem && runtime[i] == 0; i++) ! ; ! ! runtime += i; ! nelem -= i; ! avg_runtime = average_uint64(runtime, nelem, &stddevR); printf("%" PRIu64 ",", (tot_requests*1000000) / avg_runtime); printf("%" PRIu64 ",", (tot_replies*1000000) / avg_runtime); + printf("%" PRIu64 ",", aggregate[0]); printf("%" PRIu64 ",", avg_latency); + printf("%g,", stddevL); printf("%" PRIu64 ",", aggregate[aggregate_count/2]); + printf("%g,", absolute_deviation_uint64(aggregate, aggregate_count, aggregate[aggregate_count/2])); printf("%" PRIu64 ",", aggregate[aggregate_count-1]); printf("%" PRIu64 ",", aggregate_count); + printf("%" PRIu64 ",", runtime[0]); printf("%" PRIu64 ",", avg_runtime); + printf("%g,", stddevR); printf("%" PRIu64 ",", runtime[nelem/2]); printf("%" PRIu64, runtime[nelem-1]); Index: nfs_glue.c =================================================================== RCS file: /cvsroot/ipbench/ipbench2/src/tests/nfs_latency/nfs_glue.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** nfs_glue.c 10 Feb 2010 01:35:57 -0000 1.10 --- nfs_glue.c 12 Mar 2010 03:03:45 -0000 1.11 *************** *** 219,222 **** --- 219,223 ---- } + struct lookup_dir { char *tail; *************** *** 227,231 **** static void ! dir_cb(uintptr_t token, int status, struct cookie *fh, fattr_t *pattrs){ struct lookup_dir *ldp = (struct lookup_dir *)token; --- 228,233 ---- static void ! dir_cb(uintptr_t token, int status, struct cookie *fh, fattr_t *pattrs) ! { struct lookup_dir *ldp = (struct lookup_dir *)token; *************** *** 234,238 **** ldp->ok = 1; } else { ! ldp->ok = -11; } } --- 236,242 ---- ldp->ok = 1; } else { ! dbprintf("Directory %s open failed: %d\n", ! ldp->linkname, status); ! ldp->ok = -1; } } *************** *** 249,252 **** --- 253,257 ---- s = ld.tail = strdup(name); ld.cwd = *cwd; + do { ld.ok = 0; *************** *** 256,260 **** slashp = strchr(ld.linkname, '/'); if (slashp) { ! *slashp= '\0'; ld.tail = slashp + 1; dbprintf("Looking up %s\n", ld.linkname); --- 261,265 ---- slashp = strchr(ld.linkname, '/'); if (slashp) { ! *slashp = '\0'; ld.tail = slashp + 1; dbprintf("Looking up %s\n", ld.linkname); *************** *** 298,302 **** mnt_get_export_list(); if (mnt_mount(mountpoint, &pfh)) { ! printf("Can't mount\n"); return -1; } --- 303,307 ---- mnt_get_export_list(); if (mnt_mount(mountpoint, &pfh)) { ! dbprintf("Can't mount\n"); return -1; } |