[dbench @ tridge@samba.org-20070716052809-g729pk7588pgkbh2]
authorAndrew Tridgell <tridge@samba.org>
Mon, 16 Jul 2007 05:28:09 +0000 (15:28 +1000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 16 Jul 2007 05:28:09 +0000 (15:28 +1000)
show max latency

child.c
dbench.c
dbench.h

diff --git a/child.c b/child.c
index c3f97db9947ee9353bda796ef050f84d9d0f0d25..e2be37c6edd3c90c348026d71bf7d4dff885a0f7 100644 (file)
--- a/child.c
+++ b/child.c
@@ -135,7 +135,7 @@ static void child_op(struct child_struct *child, char **params,
 void child_run(struct child_struct *child0, const char *loadfile)
 {
        int i;
-       char line[1024];
+       char line[1024], fname[1024], fname2[1024];
        char **sparams, **params;
        char *p;
        const char *status;
@@ -208,16 +208,12 @@ again:
                status = params[i-1];
                
                for (child=child0;child<child0+options.clients_per_process;child++) {
-                       char *fname = NULL;
-                       char *fname2 = NULL;
-
                        if (i>1 && params[1][0] == '/') {
-                               asprintf(&fname, "%s%s", child->directory, params[1]);
+                               snprintf(fname, sizeof(fname), "%s%s", child->directory, params[1]);
                                all_string_sub(fname,"client1", child->cname);
                        }
                        if (i>2 && params[2][0] == '/') {
-                               if (fname2) free(fname2);
-                               asprintf(&fname2, "%s%s", child->directory, params[2]);
+                               snprintf(fname2, sizeof(fname2), "%s%s", child->directory, params[2]);
                                all_string_sub(fname2,"client1", child->cname);
                        }
 
@@ -229,8 +225,6 @@ again:
                        child->lasttime = timeval_current();
 
                        child_op(child, params, fname, fname2, status);
-                       if (fname) free(fname);
-                       if (fname2) free(fname2);
                }
        }
 
index d66a960982288d8730ce81a4feb564a1e1ca0381..e8088100a72cdaf1f57b190bffb19306794b946c 100644 (file)
--- a/dbench.c
+++ b/dbench.c
@@ -99,6 +99,7 @@ static void sig_alarm(int sig)
                options.warmup = 0;
                for (i=0;i<nclients;i++) {
                        children[i].bytes_done_warmup = children[i].bytes;
+                       children[i].worst_latency = 0;
                }
                goto next;
        }
@@ -116,12 +117,15 @@ static void sig_alarm(int sig)
        }
 
        latency = 0;
-       for (i=0;i<nclients;i++) {
-               latency = MAX(children[i].max_latency, latency);
-               if (!children[i].cleanup) {
+       if (!in_cleanup) {
+               for (i=0;i<nclients;i++) {
+                       latency = MAX(children[i].max_latency, latency);
                        latency = MAX(latency, timeval_elapsed2(&children[i].lasttime, &tnow));
+                       children[i].max_latency = 0;
+                       if (latency > children[i].worst_latency) {
+                               children[i].worst_latency = latency;
+                       }
                }
-               children[i].max_latency = 0;
        }
 
         if (in_warmup) {
@@ -129,9 +133,9 @@ static void sig_alarm(int sig)
                        nclients, total_lines/nclients, 
                        1.0e-6 * total_bytes / t, t, latency*1000);
         } else if (in_cleanup) {
-                printf("%4d  %8d  %7.2f MB/sec  cleanup %3.0f sec  latency %.03f ms\n", 
+                printf("%4d  %8d  %7.2f MB/sec  cleanup %3.0f sec\n", 
                        nclients, total_lines/nclients, 
-                       1.0e-6 * total_bytes / t, t, latency*1000);
+                       1.0e-6 * total_bytes / t, t);
         } else {
                 printf("%4d  %8d  %7.2f MB/sec  execute %3.0f sec  latency %.03f ms\n", 
                        nclients, total_lines/nclients, 
@@ -364,7 +368,7 @@ static int process_opts(int argc, const char **argv)
  int main(int argc, const char *argv[])
 {
        double total_bytes = 0;
-       double t;
+       double t, latency=0;
        int i;
 
        printf("dbench version %s - Copyright Andrew Tridgell 1999-2004\n\n", VERSION);
@@ -381,15 +385,17 @@ static int process_opts(int argc, const char **argv)
 
        create_procs(options.nprocs, child_run);
 
-       for (i=0;i<options.nprocs;i++) {
+       for (i=0;i<options.nprocs*options.clients_per_process;i++) {
                total_bytes += children[i].bytes - children[i].bytes_done_warmup;
+               latency = MAX(latency, children[i].worst_latency);
        }
 
        t = timeval_elapsed2(&tv_start, &tv_end);
 
-       printf("Throughput %g MB/sec%s%s %d procs\n", 
+       printf("Throughput %g MB/sec%s%s %d procs  max_latency=%.03f ms\n", 
               1.0e-6 * total_bytes / t,
               options.sync_open ? " (sync open)" : "",
-              options.sync_dirs ? " (sync dirs)" : "", options.nprocs);
+              options.sync_dirs ? " (sync dirs)" : "", 
+              options.nprocs, latency*1000);
        return 0;
 }
index 676c8096c3cbdfc1efa7d341a90fde1df298f808..4e6d7e8524c62d3ab60f698e7ff2b46ec496b2ff 100644 (file)
--- a/dbench.h
+++ b/dbench.h
@@ -102,6 +102,7 @@ struct child_struct {
        double bytes;
        double bytes_done_warmup;
        double max_latency;
+       double worst_latency;
        struct timeval starttime;
        struct timeval lasttime;
        off_t bytes_since_fsync;