added a 5% warmup time to NBENCH to make the results more consistent
authorAndrew Tridgell <tridge@samba.org>
Wed, 10 Mar 2004 03:24:03 +0000 (03:24 +0000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 10 Mar 2004 03:24:03 +0000 (03:24 +0000)
source/torture/nbench/nbench.c
source/torture/nbench/nbio.c

index 3da7dedae138044b26c6e2c80a8fb53c6ce633c3..3a5d9bef70ce6cd9984d3825e2c39e4909feb893 100644 (file)
@@ -22,6 +22,7 @@
 
 int nbench_line_count = 0;
 static int timelimit = 600;
+static int warmup;
 static char *loadfile;
 
 #define ival(s) strtol(s, NULL, 0)
@@ -37,7 +38,7 @@ static BOOL run_netbench(struct cli_state *cli, int client)
        const char *p;
        BOOL correct = True;
 
-       nb_setup(cli, client);
+       nb_setup(cli, client, warmup);
 
        asprintf(&cname, "client%d", client);
 
@@ -51,6 +52,13 @@ static BOOL run_netbench(struct cli_state *cli, int client)
 again:
        while (fgets(line, sizeof(line)-1, f)) {
                NTSTATUS status;
+               double t = end_timer();
+
+               if (warmup && t >= warmup) {
+                       warmup = 0;
+                       nb_warmup_done();
+                       start_timer();
+               }
 
                if (end_timer() >= timelimit) {
                        goto done;
@@ -152,7 +160,6 @@ done:
 /* run a test that simulates an approximate netbench client load */
 BOOL torture_nbench(int dummy)
 {
-       double t;
        BOOL correct = True;
        extern int torture_nprocs;
        struct cli_state *cli;
@@ -163,6 +170,8 @@ BOOL torture_nbench(int dummy)
                timelimit = atoi(p);
        }
 
+       warmup = timelimit / 20;
+
        loadfile =  lp_parm_string(-1, "torture", "loadfile");
        if (!loadfile || !*loadfile) {
                loadfile = "client.txt";
@@ -172,19 +181,20 @@ BOOL torture_nbench(int dummy)
                return False;
        }
 
-       nb_setup(cli, -1);
+       nb_setup(cli, -1, warmup);
        nb_deltree("\\clients");
 
        nbio_shmem(torture_nprocs);
 
-       printf("Running for %d seconds with load '%s'\n", timelimit, loadfile);
+       printf("Running for %d seconds with load '%s' and warmup %d secs\n", 
+              timelimit, loadfile, warmup);
 
        signal(SIGALRM, SIGNAL_CAST nb_alarm);
        alarm(1);
-       t = torture_create_procs(run_netbench, &correct);
+       torture_create_procs(run_netbench, &correct);
        alarm(0);
 
        printf("\nThroughput %g MB/sec\n", 
-              1.0e-6 * nbio_total() / t);
+              1.0e-6 * nbio_total() / timelimit);
        return correct;
 }
index b2058249bd1a82adb0c2bf8563a30106af5a89c0..fee3af05e4a0b0201115c60bec1017e9928b3618 100644 (file)
@@ -28,6 +28,7 @@ extern int nbench_line_count;
 static int nbio_id;
 static int nprocs;
 static BOOL bypass_io;
+static int warmup;
 
 static struct {
        int fd;
@@ -50,6 +51,13 @@ double nbio_total(void)
        return total;
 }
 
+void nb_warmup_done(void)
+{
+       children[nbio_id].bytes_out = 0;
+       children[nbio_id].bytes_in = 0;
+}
+
+
 void nb_alarm(void)
 {
        int i;
@@ -65,10 +73,15 @@ void nb_alarm(void)
 
        t = end_timer();
 
-       printf("%4d  %8d  %.2f MB/sec  t=%.0f    \r", 
+       printf("%4d  %8d  %.2f MB/sec  time %.0f sec   \r", 
               num_clients, lines/nprocs, 
               1.0e-6 * nbio_total() / t, 
-              t);
+              t - warmup);
+
+       if (warmup && t >= warmup) {
+               start_timer();
+               warmup = 0;
+       }
 
        signal(SIGALRM, nb_alarm);
        alarm(1);       
@@ -101,8 +114,9 @@ static int find_handle(int handle)
 
 static struct cli_state *c;
 
-void nb_setup(struct cli_state *cli, int id)
+void nb_setup(struct cli_state *cli, int id, int warmupt)
 {
+       warmup = warmupt;
        nbio_id = id;
        c = cli;
        start_timer();
@@ -245,7 +259,6 @@ void nb_writex(int handle, int offset, int size, int ret_size, NTSTATUS status)
        children[nbio_id].bytes_out += ret_size;
 }
 
-
 void nb_write(int handle, int offset, int size, int ret_size, NTSTATUS status)
 {
        union smb_write io;