diff --git a/CMakeLists.txt b/CMakeLists.txt index f5f1765..c637dac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,8 +35,8 @@ if (CMAKE_C_COMPILER MATCHES ".*clang") endif () # Options -option(GMIO_BUILD_STRICT_C90 "Build with strict conformance to C90 standard" OFF) -option(GMIO_BENCHMARKS "Build performance benchmarks for the gmio library" OFF) +option(GMIO_BUILD_STRICT_C90 "Build gmio library(and tests) with strict conformance to C90 standard" OFF) +option(GMIO_BUILD_BENCHMARKS "Build performance benchmarks for the gmio library" OFF) # Find bit size of the target architecture math(EXPR GMIO_TARGET_ARCH_BIT_SIZE "8 * ${CMAKE_SIZEOF_VOID_P}") @@ -186,7 +186,7 @@ endif() add_subdirectory(src) add_subdirectory(tests) add_subdirectory(doc) -if(GMIO_BENCHMARKS) +if(GMIO_BUILD_BENCHMARKS) add_subdirectory(benchmarks) endif() diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 2093baf..f0b46b9 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -14,8 +14,8 @@ ############################################################################# # Options -option(GMIO_BENCHMARKS_ASSIMP "Build benchmark for Assimp" ON) -option(GMIO_BENCHMARKS_OPENCASCADE "Build benchmark for OpenCascade" ON) +option(GMIO_BUILD_BENCHMARK_ASSIMP "Build benchmark for Assimp" ON) +option(GMIO_BUILD_BENCHMARK_OPENCASCADE "Build benchmark for OpenCascade" ON) set(ASSIMP_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Directory where the Assimp library resides") set(OPENCASCADE_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Directory where the OpenCascade library resides") @@ -37,7 +37,7 @@ if(CMAKE_COMPILER_IS_GNUCC) link_libraries(m) # -lm endif() -add_executable(bench_gmio bench_gmio/main.c ${COMMONS_FILES}) +add_executable(benchmark_gmio benchmark_gmio/main.c ${COMMONS_FILES}) function(get_msvc_vernum outVerNum) if(MSVC60) @@ -57,43 +57,43 @@ function(get_msvc_vernum outVerNum) endif() endfunction() -if(GMIO_BENCHMARKS_ASSIMP) - add_executable(bench_assimp bench_assimp/main.cpp ${COMMONS_FILES}) +if(GMIO_BUILD_BENCHMARK_ASSIMP) + add_executable(benchmark_assimp benchmark_assimp/main.cpp ${COMMONS_FILES}) # Note: we could use target_include_directories() but it's available in cmake > v2.8.10 set_property( - TARGET bench_assimp + TARGET benchmark_assimp APPEND PROPERTY INCLUDE_DIRECTORIES ${ASSIMP_DIR}/include) # Libs find_library(LIBPATH_ASSIMP assimp ${ASSIMP_DIR}/lib64) - target_link_libraries(bench_assimp ${LIBPATH_ASSIMP}) + target_link_libraries(benchmark_assimp ${LIBPATH_ASSIMP}) endif() -if(GMIO_BENCHMARKS_OPENCASCADE) - add_executable(bench_occ - bench_occ/main.cpp +if(GMIO_BUILD_BENCHMARK_OPENCASCADE) + add_executable(benchmark_opencascade + benchmark_opencascade/main.cpp ${CMAKE_SOURCE_DIR}/src/gmio_support/stl_occ.cpp ${COMMONS_FILES}) # TODO: define only if target arch is 64b # Note: we could use target_compile_definitions() but it's available in cmake > v2.8.10 set_property( - TARGET bench_occ + TARGET benchmark_opencascade APPEND PROPERTY COMPILE_DEFINITIONS _OCC64) if(WIN32) set_property( - TARGET bench_occ + TARGET benchmark_opencascade APPEND PROPERTY COMPILE_DEFINITIONS WNT) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") set_property( - TARGET bench_occ + TARGET benchmark_opencascade APPEND PROPERTY COMPILE_DEFINITIONS HAVE_CONFIG_H HAVE_FSTREAM HAVE_IOSTREAM HAVE_IOMANIP HAVE_LIMITS_H) endif() # Note: we could use target_include_directories() but it's available in cmake > v2.8.10 set_property( - TARGET bench_occ + TARGET benchmark_opencascade APPEND PROPERTY INCLUDE_DIRECTORIES ${OPENCASCADE_DIR}/inc) # Libs @@ -110,7 +110,7 @@ if(GMIO_BENCHMARKS_OPENCASCADE) find_library(LIBPATH_OPENCASCADE_TKMATH TKMath ${OPENCASCADE_LIBDIR}) find_library(LIBPATH_OPENCASCADE_TKSTL TKSTL ${OPENCASCADE_LIBDIR}) target_link_libraries( - bench_occ + benchmark_opencascade ${LIBPATH_OPENCASCADE_TKERNEL} ${LIBPATH_OPENCASCADE_TKMATH} ${LIBPATH_OPENCASCADE_TKSTL}) diff --git a/benchmarks/bench_assimp/main.cpp b/benchmarks/benchmark_assimp/main.cpp similarity index 99% rename from benchmarks/bench_assimp/main.cpp rename to benchmarks/benchmark_assimp/main.cpp index b1e4518..c977386 100644 --- a/benchmarks/bench_assimp/main.cpp +++ b/benchmarks/benchmark_assimp/main.cpp @@ -13,7 +13,7 @@ ** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html". ****************************************************************************/ -#include "../commons/bench_tools.h" +#include "../commons/benchmark_tools.h" #include #include diff --git a/benchmarks/bench_gmio/main.c b/benchmarks/benchmark_gmio/main.c similarity index 99% rename from benchmarks/bench_gmio/main.c rename to benchmarks/benchmark_gmio/main.c index 82b0b73..3167a0b 100644 --- a/benchmarks/bench_gmio/main.c +++ b/benchmarks/benchmark_gmio/main.c @@ -16,7 +16,7 @@ #include #include -#include "../commons/bench_tools.h" +#include "../commons/benchmark_tools.h" #include diff --git a/benchmarks/bench_occ/main.cpp b/benchmarks/benchmark_opencascade/main.cpp similarity index 98% rename from benchmarks/bench_occ/main.cpp rename to benchmarks/benchmark_opencascade/main.cpp index 9f571f0..72bf14a 100644 --- a/benchmarks/bench_occ/main.cpp +++ b/benchmarks/benchmark_opencascade/main.cpp @@ -21,7 +21,7 @@ #include #include -#include "../commons/bench_tools.h" +#include "../commons/benchmark_tools.h" namespace BenchmarkOcc { diff --git a/benchmarks/commons/bench_tools.c b/benchmarks/commons/benchmark_tools.c similarity index 72% rename from benchmarks/commons/bench_tools.c rename to benchmarks/commons/benchmark_tools.c index 1249a7f..d2cd896 100644 --- a/benchmarks/commons/bench_tools.c +++ b/benchmarks/commons/benchmark_tools.c @@ -13,40 +13,40 @@ ** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html". ****************************************************************************/ -#include "bench_tools.h" +#include "benchmark_tools.h" #include #ifdef WIN32 # include -# define BENCH_TIMER_WINDOWS +# define BENCHMARK_TIMER_WINDOWS #else -# define BENCH_TIMER_LIBC +# define BENCHMARK_TIMER_LIBC #endif -typedef struct bench_timer +typedef struct benchmark_timer { -#ifdef BENCH_TIMER_WINDOWS +#ifdef BENCHMARK_TIMER_WINDOWS LARGE_INTEGER start_time; LARGE_INTEGER frequency; -#elif defined(BENCH_TIMER_LIBC) +#elif defined(BENCHMARK_TIMER_LIBC) clock_t start_tick; #endif -} bench_timer_t; +} benchmark_timer_t; -void bench_timer_start(bench_timer_t* timer) +void benchmark_timer_start(benchmark_timer_t* timer) { -#ifdef BENCH_TIMER_WINDOWS +#ifdef BENCHMARK_TIMER_WINDOWS QueryPerformanceFrequency(&timer->frequency); QueryPerformanceCounter(&timer->start_time); -#elif defined(BENCH_TIMER_LIBC) +#elif defined(BENCHMARK_TIMER_LIBC) timer->start_tick = clock(); #endif } -int64_t bench_timer_elapsed_ms(const bench_timer_t* timer) +int64_t benchmark_timer_elapsed_ms(const benchmark_timer_t* timer) { -#ifdef BENCH_TIMER_WINDOWS +#ifdef BENCHMARK_TIMER_WINDOWS LARGE_INTEGER end_time = { 0 }; LARGE_INTEGER elapsed = { 0 }; QueryPerformanceCounter(&end_time); @@ -63,7 +63,7 @@ int64_t bench_timer_elapsed_ms(const bench_timer_t* timer) elapsed.QuadPart *= 1000; elapsed.QuadPart /= timer->frequency.QuadPart; return elapsed.QuadPart; -#elif defined(BENCH_TIMER_LIBC) +#elif defined(BENCHMARK_TIMER_LIBC) /* For seconds: * return (float)((clock() - start_tick) / (float)CLOCKS_PER_SEC); */ return clock() - timer->start_tick; @@ -71,15 +71,15 @@ int64_t bench_timer_elapsed_ms(const bench_timer_t* timer) } void benchmark_list( - bench_file_func_t func, const char* title, int argc, char **argv) + benchmark_file_func_t func, const char* title, int argc, char **argv) { - bench_timer_t timer = { 0 }; + benchmark_timer_t timer = { 0 }; int iarg; if (func == NULL) return; - bench_timer_start(&timer); + benchmark_timer_start(&timer); printf("Bench %s ...\n", title); for (iarg = 0; iarg < argc; ++iarg) { @@ -87,10 +87,10 @@ void benchmark_list( (*func)(argv[iarg]); } /*printf(" exec time: %.2fs\n\n", elapsed_secs(start_tick));*/ - printf(" exec time: %lldms\n\n", bench_timer_elapsed_ms(&timer)); + printf(" exec time: %lldms\n\n", benchmark_timer_elapsed_ms(&timer)); } -void benchmark_forward_list(bench_file_func_t func, int argc, char **argv) +void benchmark_forward_list(benchmark_file_func_t func, int argc, char **argv) { int i = 0; while (i < argc) { @@ -100,7 +100,7 @@ void benchmark_forward_list(bench_file_func_t func, int argc, char **argv) } void benchmark( - bench_file_func_t func, const char *title, const char* filepath) + benchmark_file_func_t func, const char *title, const char* filepath) { benchmark_list(func, title, 1, (char**)&filepath); } diff --git a/benchmarks/commons/bench_tools.h b/benchmarks/commons/benchmark_tools.h similarity index 70% rename from benchmarks/commons/bench_tools.h rename to benchmarks/commons/benchmark_tools.h index faf5456..9c9b102 100644 --- a/benchmarks/commons/bench_tools.h +++ b/benchmarks/commons/benchmark_tools.h @@ -13,24 +13,24 @@ ** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html". ****************************************************************************/ -#ifndef BENCH_TOOLS_H -#define BENCH_TOOLS_H +#ifndef BENCHMARK_TOOLS_H +#define BENCHMARK_TOOLS_H #include GMIO_C_LINKAGE_BEGIN -typedef void (*bench_file_func_t)(const char*); +typedef void (*benchmark_file_func_t)(const char*); void benchmark_list( - bench_file_func_t func, const char* title, int argc, char** argv); + benchmark_file_func_t func, const char* title, int argc, char** argv); void benchmark_forward_list( - bench_file_func_t func, int argc, char** argv); + benchmark_file_func_t func, int argc, char** argv); void benchmark( - bench_file_func_t func, const char* title, const char* filepath); + benchmark_file_func_t func, const char* title, const char* filepath); GMIO_C_LINKAGE_END -#endif /* BENCH_TOOLS_H */ +#endif /* BENCHMARK_TOOLS_H */