diff options
Diffstat (limited to 'src/bench/main.c')
-rw-r--r-- | src/bench/main.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/src/bench/main.c b/src/bench/main.c index 2f32dbf..37e2821 100644 --- a/src/bench/main.c +++ b/src/bench/main.c @@ -4,8 +4,9 @@ #include "connection.h" #include "helper.h" -#include "../shared/protocol.h" -#include "../shared/log.h" +#include <dnbd3/shared/protocol.h> +#include <dnbd3/shared/log.h> +#include <dnbd3/version.h> #include <stdio.h> #include <stdlib.h> @@ -17,12 +18,9 @@ #define debugf(...) do { logadd( LOG_DEBUG1, __VA_ARGS__ ); } while (0) -/* Debug/Benchmark variables */ -static bool useDebug = false; - - static void printUsage(char *argv0, int exitCode) { + printf( "Version: %s\n", DNBD3_VERSION_LONG ); printf( "Usage: %s [--debug] --host <serverAddress(es)> --image <imageName> [--rid revision]\n", argv0 ); printf( "Or: %s [-d] -h <serverAddress(es)> -i <imageName> [-r revision]\n", argv0 ); printf( " -h --host List of space separated hosts to use\n" ); @@ -30,19 +28,18 @@ static void printUsage(char *argv0, int exitCode) printf( " -r --rid Revision to use (omit or pass 0 for latest)\n" ); printf( " -n --runs Number of connection attempts per thread\n" ); printf( " -t --threads number of threads\n" ); - printf( " -l --log Write log to given location\n" ); - printf( " -d --debug Don't fork and print debug output (fuse > stderr, dnbd3 > stdout)\n" ); - // // fuse_main( 2, arg, &dnbd3_fuse_no_operations, NULL ); + printf( " -b --blocksize Size of blocks to request (def. 4096)\n" ); exit( exitCode ); } -static const char *optString = "h:i:n:t:HvVd"; +static const char *optString = "b:h:i:n:t:Hv"; static const struct option longOpts[] = { { "host", required_argument, NULL, 'h' }, { "image", required_argument, NULL, 'i' }, { "nruns", optional_argument, NULL, 'n' }, - { "threads", optional_argument, NULL, 't' }, - { "help", optional_argument, NULL, 'H' }, + { "threads", required_argument, NULL, 't' }, + { "blocksize", required_argument, NULL, 'b' }, + { "help", no_argument, NULL, 'H' }, { "version", no_argument, NULL, 'v' }, { 0, 0, 0, 0 } }; @@ -59,11 +56,11 @@ void* runBenchThread(void* t) { BenchThreadData* data = t; connection_init_n_times( data->server_address, - data->server_address, + data->image_name, 0, data->runs, - data->counter, - data->closeSockets); + data->bs, + data->counter); printf("Thread #%d finished\n", data->threadNumber); return NULL; } @@ -77,6 +74,9 @@ int main(int argc, char *argv[]) bool closeSockets = false; int n_runs = 100; int n_threads = 1; + int bs = 4096; + + log_init(); if ( argc <= 1 || strcmp( argv[1], "--help" ) == 0 || strcmp( argv[1], "--usage" ) == 0 ) { printUsage( argv[0], 0 ); @@ -85,10 +85,10 @@ int main(int argc, char *argv[]) while ( ( opt = getopt_long( argc, argv, optString, longOpts, &lidx ) ) != -1 ) { switch ( opt ) { case 'h': - server_address = optarg; + server_address = strdup(optarg); break; case 'i': - image_Name = optarg; + image_Name = strdup(optarg); break; case 'n': n_runs = atoi(optarg); @@ -96,15 +96,15 @@ int main(int argc, char *argv[]) case 't': n_threads = atoi(optarg); break; + case 'b': + bs = atoi(optarg); + break; case 'c': closeSockets = true; break; case 'H': printUsage( argv[0], 0 ); break; - case 'd': - useDebug = true; - break; default: printUsage( argv[0], EXIT_FAILURE ); } @@ -126,6 +126,7 @@ int main(int argc, char *argv[]) server_address, image_Name, n_runs, + bs, i, closeSockets}; threadData[i] = tmp2; |