diff options
Diffstat (limited to 'src/bench')
-rw-r--r-- | src/bench/CMakeLists.txt | 22 | ||||
-rw-r--r-- | src/bench/connection.c | 12 | ||||
-rw-r--r-- | src/bench/connection.h | 2 | ||||
-rw-r--r-- | src/bench/helper.h | 2 | ||||
-rw-r--r-- | src/bench/main.c | 8 | ||||
-rw-r--r-- | src/bench/serialize.c | 5 |
6 files changed, 36 insertions, 15 deletions
diff --git a/src/bench/CMakeLists.txt b/src/bench/CMakeLists.txt new file mode 100644 index 0000000..24542a7 --- /dev/null +++ b/src/bench/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.10) + +# set the project name +project(dnbd3-bench + LANGUAGES C) + +# add compile option to enable enhanced POSIX pthread features +add_definitions(-D_GNU_SOURCE) + +set(DNBD3_BENCH_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/connection.c + ${CMAKE_CURRENT_SOURCE_DIR}/helper.c + ${CMAKE_CURRENT_SOURCE_DIR}/main.c) +set(DNBD3_BENCH_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/connection.h + ${CMAKE_CURRENT_SOURCE_DIR}/helper.h) + +add_executable(dnbd3-bench ${DNBD3_BENCH_SOURCE_FILES}) +target_link_libraries(dnbd3-bench dnbd3-version dnbd3-shared ${CMAKE_THREAD_LIBS_INIT}) +install(TARGETS dnbd3-bench RUNTIME DESTINATION bin + COMPONENT bench) + +add_linter(dnbd3-bench-lint "${DNBD3_BENCH_SOURCE_FILES}" "${DNBD3_BENCH_HEADER_FILES}") +add_linter_fix(dnbd3-bench-lint-fix "${DNBD3_BENCH_SOURCE_FILES}" "${DNBD3_BENCH_HEADER_FILES}") diff --git a/src/bench/connection.c b/src/bench/connection.c index 26be440..974bc8a 100644 --- a/src/bench/connection.c +++ b/src/bench/connection.c @@ -1,10 +1,10 @@ #include "connection.h" #include "helper.h" -#include "../config.h" -#include "../shared/protocol.h" -#include "../shared/fdsignal.h" -#include "../shared/sockhelper.h" -#include "../shared/log.h" +#include <dnbd3/config.h> +#include <dnbd3/shared/protocol.h> +#include <dnbd3/shared/fdsignal.h> +#include <dnbd3/shared/sockhelper.h> +#include <dnbd3/shared/log.h> #include <stdlib.h> #include <pthread.h> @@ -97,7 +97,7 @@ bool connection_init_n_times( counters->fails++; logadd( LOG_ERROR, "rid mismatch" ); //} else if ( !dnbd3_get_block( sock, run_i * blockSize, blockSize, 0, 0 ) ) { - } else if ( !dnbd3_get_block( sock, (((uint64_t)rand()) << 16 + rand()) % (remoteSize - blockSize), blockSize, 0, 0 ) ) { + } else if ( !dnbd3_get_block( sock, (((uint64_t)rand() << 16) + rand()) % (remoteSize - blockSize), blockSize, 0, 0 ) ) { counters->fails++; logadd( LOG_ERROR, "send: get block failed" ); } else if ( !dnbd3_get_reply( sock, &reply ) ) { diff --git a/src/bench/connection.h b/src/bench/connection.h index 770bf0d..422c93e 100644 --- a/src/bench/connection.h +++ b/src/bench/connection.h @@ -1,7 +1,7 @@ #ifndef _CONNECTION_H_ #define _CONNECTION_H_ -#include "../shared/fdsignal.h" +#include <dnbd3/shared/fdsignal.h> #include <stdbool.h> #include <stdint.h> #include "helper.h" diff --git a/src/bench/helper.h b/src/bench/helper.h index e0c0262..53f32bf 100644 --- a/src/bench/helper.h +++ b/src/bench/helper.h @@ -1,7 +1,7 @@ #ifndef IMAGEHELPER_H #define IMAGEHELPER_H -#include "../types.h" +#include <dnbd3/types.h> #include <netdb.h> #include <stdbool.h> diff --git a/src/bench/main.c b/src/bench/main.c index f8c55c3..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> @@ -19,6 +20,7 @@ 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" ); @@ -74,6 +76,8 @@ int main(int argc, char *argv[]) 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 ); } diff --git a/src/bench/serialize.c b/src/bench/serialize.c deleted file mode 100644 index 4934132..0000000 --- a/src/bench/serialize.c +++ /dev/null @@ -1,5 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <stdint.h> - -#include "../serialize.c" |