r5298: - got rid of pstring.h from includes.h. This at least makes it a bit
[kai/samba.git] / source / torture / nbench / nbench.c
index a649b5fa159288dccf4b2a55640ca9c83140d6a8..748ff90467462255c82fc59f1b042d179ae528ac 100644 (file)
@@ -19,6 +19,8 @@
 */
 
 #include "includes.h"
+#include "system/filesys.h"
+#include "pstring.h"
 
 int nbench_line_count = 0;
 static int timelimit = 600;
@@ -38,7 +40,7 @@ static BOOL run_netbench(struct smbcli_state *cli, int client)
        const char *p;
        BOOL correct = True;
 
-       nb_setup(cli, client, warmup);
+       nb_setup(cli, client);
 
        asprintf(&cname, "client%d", client+1);
 
@@ -52,17 +54,6 @@ static BOOL run_netbench(struct smbcli_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;
-               }
 
                nbench_line_count++;
 
@@ -144,6 +135,8 @@ again:
                } else {
                        printf("[%d] Unknown operation %s\n", nbench_line_count, params[0]);
                }
+               
+               if (nb_tick()) goto done;
        }
 
        rewind(f);
@@ -151,7 +144,6 @@ again:
 
 done:
        fclose(f);
-       nb_cleanup(cname);
 
        if (!torture_close_connection(cli)) {
                correct = False;
@@ -162,7 +154,7 @@ done:
 
 
 /* run a test that simulates an approximate netbench client load */
-BOOL torture_nbench(int dummy)
+BOOL torture_nbench(void)
 {
        BOOL correct = True;
        extern int torture_nprocs;
@@ -185,20 +177,22 @@ BOOL torture_nbench(int dummy)
                return False;
        }
 
-       nb_setup(cli, -1, warmup);
-       nb_deltree("\\clients");
+       if (!torture_setup_dir(cli, "\\clients")) {
+               return False;
+       }
 
-       nbio_shmem(torture_nprocs);
+       nbio_shmem(torture_nprocs, timelimit, warmup);
 
        printf("Running for %d seconds with load '%s' and warmup %d secs\n", 
               timelimit, loadfile, warmup);
 
-       signal(SIGALRM, SIGNAL_CAST nb_alarm);
+       signal(SIGALRM, nb_alarm);
        alarm(1);
        torture_create_procs(run_netbench, &correct);
        alarm(0);
 
-       printf("\nThroughput %g MB/sec\n", 
-              1.0e-6 * nbio_total() / timelimit);
+       smbcli_deltree(cli->tree, "\\clients");
+
+       printf("\nThroughput %g MB/sec\n", nbio_result());
        return correct;
 }