Author: tridge
Date: 2007-05-17 02:22:29 +0000 (Thu, 17 May 2007)
New Revision: 22962

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=22962

Log:

show progress separately for each client in RAW-BENCH-LOCK, this is
much more useful for seeing why we get unbalanced locking

Modified:
   branches/SAMBA_4_0/source/torture/raw/lockbench.c


Changeset:
Modified: branches/SAMBA_4_0/source/torture/raw/lockbench.c
===================================================================
--- branches/SAMBA_4_0/source/torture/raw/lockbench.c   2007-05-17 02:21:07 UTC 
(rev 22961)
+++ branches/SAMBA_4_0/source/torture/raw/lockbench.c   2007-05-17 02:22:29 UTC 
(rev 22962)
@@ -54,6 +54,7 @@
        int fnum;
        int offset;
        int count;
+       int lastcount;
        union smb_lock io;
        struct smb_lock_entry lock[2];
        struct smbcli_request *req;
@@ -216,6 +217,22 @@
        }
 }
 
+
+static void report_rate(struct event_context *ev, struct timed_event *te, 
+                       struct timeval t, void *private_data)
+{
+       struct benchlock_state *state = talloc_get_type(private_data, 
+                                                       struct benchlock_state);
+       int i;
+       for (i=0;i<nprocs;i++) {
+               printf("%5u ", (unsigned)(state[i].count - state[i].lastcount));
+               state[i].lastcount = state[i].count;
+       }
+       printf("\r");
+       fflush(stdout);
+       event_add_timed(ev, state, timeval_current_ofs(1, 0), report_rate, 
state);
+}
+
 /* 
    benchmark locking calls
 */
@@ -228,10 +245,13 @@
        struct timeval tv;
        struct event_context *ev = event_context_find(mem_ctx);
        struct benchlock_state *state;
-       int total = 0, loops=0, minops=0;
+       int total = 0, minops=0;
        NTSTATUS status;
        struct smbcli_state *cli;
-       
+       bool progress;
+
+       progress = torture_setting_bool(torture, "progress", true);
+
        nprocs = lp_parm_int(-1, "torture", "nprocs", 4);
 
        state = talloc_zero_array(mem_ctx, struct benchlock_state, nprocs);
@@ -293,6 +313,10 @@
 
        tv = timeval_current(); 
 
+       if (progress) {
+               event_add_timed(ev, state, timeval_current_ofs(1, 0), 
report_rate, state);
+       }
+
        printf("Running for %d seconds\n", timelimit);
        while (timeval_elapsed(&tv) < timelimit) {
                event_loop_once(ev);
@@ -301,19 +325,6 @@
                        DEBUG(0,("locking failed\n"));
                        goto failed;
                }
-
-               if (loops++ % 10 != 0) continue;
-
-               total = 0;
-               for (i=0;i<nprocs;i++) {
-                       total += state[i].count;
-               }
-               if (torture_setting_bool(torture, "progress", true)) {
-                       printf("%.2f ops/second (remaining=%u)\r", 
-                              total/timeval_elapsed(&tv), 
-                              (unsigned)(timelimit - timeval_elapsed(&tv)));
-                       fflush(stdout);
-               }
        }
 
        printf("%.2f ops/second\n", total/timeval_elapsed(&tv));

Reply via email to