benchmarks: bench_ -> benchmark_
This commit is contained in:
parent
2f6af3ed26
commit
deccace38b
@ -35,8 +35,8 @@ if (CMAKE_C_COMPILER MATCHES ".*clang")
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
option(GMIO_BUILD_STRICT_C90 "Build with strict conformance to C90 standard" OFF)
|
option(GMIO_BUILD_STRICT_C90 "Build gmio library(and tests) with strict conformance to C90 standard" OFF)
|
||||||
option(GMIO_BENCHMARKS "Build performance benchmarks for the gmio library" OFF)
|
option(GMIO_BUILD_BENCHMARKS "Build performance benchmarks for the gmio library" OFF)
|
||||||
|
|
||||||
# Find bit size of the target architecture
|
# Find bit size of the target architecture
|
||||||
math(EXPR GMIO_TARGET_ARCH_BIT_SIZE "8 * ${CMAKE_SIZEOF_VOID_P}")
|
math(EXPR GMIO_TARGET_ARCH_BIT_SIZE "8 * ${CMAKE_SIZEOF_VOID_P}")
|
||||||
@ -186,7 +186,7 @@ endif()
|
|||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
add_subdirectory(doc)
|
add_subdirectory(doc)
|
||||||
if(GMIO_BENCHMARKS)
|
if(GMIO_BUILD_BENCHMARKS)
|
||||||
add_subdirectory(benchmarks)
|
add_subdirectory(benchmarks)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
option(GMIO_BENCHMARKS_ASSIMP "Build benchmark for Assimp" ON)
|
option(GMIO_BUILD_BENCHMARK_ASSIMP "Build benchmark for Assimp" ON)
|
||||||
option(GMIO_BENCHMARKS_OPENCASCADE "Build benchmark for OpenCascade" 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(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")
|
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
|
link_libraries(m) # -lm
|
||||||
endif()
|
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)
|
function(get_msvc_vernum outVerNum)
|
||||||
if(MSVC60)
|
if(MSVC60)
|
||||||
@ -57,43 +57,43 @@ function(get_msvc_vernum outVerNum)
|
|||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
if(GMIO_BENCHMARKS_ASSIMP)
|
if(GMIO_BUILD_BENCHMARK_ASSIMP)
|
||||||
add_executable(bench_assimp bench_assimp/main.cpp ${COMMONS_FILES})
|
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
|
# Note: we could use target_include_directories() but it's available in cmake > v2.8.10
|
||||||
set_property(
|
set_property(
|
||||||
TARGET bench_assimp
|
TARGET benchmark_assimp
|
||||||
APPEND PROPERTY INCLUDE_DIRECTORIES ${ASSIMP_DIR}/include)
|
APPEND PROPERTY INCLUDE_DIRECTORIES ${ASSIMP_DIR}/include)
|
||||||
# Libs
|
# Libs
|
||||||
find_library(LIBPATH_ASSIMP assimp ${ASSIMP_DIR}/lib64)
|
find_library(LIBPATH_ASSIMP assimp ${ASSIMP_DIR}/lib64)
|
||||||
target_link_libraries(bench_assimp ${LIBPATH_ASSIMP})
|
target_link_libraries(benchmark_assimp ${LIBPATH_ASSIMP})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(GMIO_BENCHMARKS_OPENCASCADE)
|
if(GMIO_BUILD_BENCHMARK_OPENCASCADE)
|
||||||
add_executable(bench_occ
|
add_executable(benchmark_opencascade
|
||||||
bench_occ/main.cpp
|
benchmark_opencascade/main.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/gmio_support/stl_occ.cpp
|
${CMAKE_SOURCE_DIR}/src/gmio_support/stl_occ.cpp
|
||||||
${COMMONS_FILES})
|
${COMMONS_FILES})
|
||||||
|
|
||||||
# TODO: define only if target arch is 64b
|
# TODO: define only if target arch is 64b
|
||||||
# Note: we could use target_compile_definitions() but it's available in cmake > v2.8.10
|
# Note: we could use target_compile_definitions() but it's available in cmake > v2.8.10
|
||||||
set_property(
|
set_property(
|
||||||
TARGET bench_occ
|
TARGET benchmark_opencascade
|
||||||
APPEND PROPERTY COMPILE_DEFINITIONS _OCC64)
|
APPEND PROPERTY COMPILE_DEFINITIONS _OCC64)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set_property(
|
set_property(
|
||||||
TARGET bench_occ
|
TARGET benchmark_opencascade
|
||||||
APPEND PROPERTY COMPILE_DEFINITIONS WNT)
|
APPEND PROPERTY COMPILE_DEFINITIONS WNT)
|
||||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||||
set_property(
|
set_property(
|
||||||
TARGET bench_occ
|
TARGET benchmark_opencascade
|
||||||
APPEND PROPERTY COMPILE_DEFINITIONS
|
APPEND PROPERTY COMPILE_DEFINITIONS
|
||||||
HAVE_CONFIG_H HAVE_FSTREAM HAVE_IOSTREAM HAVE_IOMANIP HAVE_LIMITS_H)
|
HAVE_CONFIG_H HAVE_FSTREAM HAVE_IOSTREAM HAVE_IOMANIP HAVE_LIMITS_H)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Note: we could use target_include_directories() but it's available in cmake > v2.8.10
|
# Note: we could use target_include_directories() but it's available in cmake > v2.8.10
|
||||||
set_property(
|
set_property(
|
||||||
TARGET bench_occ
|
TARGET benchmark_opencascade
|
||||||
APPEND PROPERTY INCLUDE_DIRECTORIES ${OPENCASCADE_DIR}/inc)
|
APPEND PROPERTY INCLUDE_DIRECTORIES ${OPENCASCADE_DIR}/inc)
|
||||||
|
|
||||||
# Libs
|
# Libs
|
||||||
@ -110,7 +110,7 @@ if(GMIO_BENCHMARKS_OPENCASCADE)
|
|||||||
find_library(LIBPATH_OPENCASCADE_TKMATH TKMath ${OPENCASCADE_LIBDIR})
|
find_library(LIBPATH_OPENCASCADE_TKMATH TKMath ${OPENCASCADE_LIBDIR})
|
||||||
find_library(LIBPATH_OPENCASCADE_TKSTL TKSTL ${OPENCASCADE_LIBDIR})
|
find_library(LIBPATH_OPENCASCADE_TKSTL TKSTL ${OPENCASCADE_LIBDIR})
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
bench_occ
|
benchmark_opencascade
|
||||||
${LIBPATH_OPENCASCADE_TKERNEL}
|
${LIBPATH_OPENCASCADE_TKERNEL}
|
||||||
${LIBPATH_OPENCASCADE_TKMATH}
|
${LIBPATH_OPENCASCADE_TKMATH}
|
||||||
${LIBPATH_OPENCASCADE_TKSTL})
|
${LIBPATH_OPENCASCADE_TKSTL})
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "../commons/bench_tools.h"
|
#include "../commons/benchmark_tools.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
#include <assimp/Exporter.hpp>
|
#include <assimp/Exporter.hpp>
|
@ -16,7 +16,7 @@
|
|||||||
#include <gmio_core/error.h>
|
#include <gmio_core/error.h>
|
||||||
#include <gmio_stl/stl_io.h>
|
#include <gmio_stl/stl_io.h>
|
||||||
|
|
||||||
#include "../commons/bench_tools.h"
|
#include "../commons/benchmark_tools.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
@ -21,7 +21,7 @@
|
|||||||
#include <gmio_stl/stl_io.h>
|
#include <gmio_stl/stl_io.h>
|
||||||
#include <gmio_support/stl_occ.h>
|
#include <gmio_support/stl_occ.h>
|
||||||
|
|
||||||
#include "../commons/bench_tools.h"
|
#include "../commons/benchmark_tools.h"
|
||||||
|
|
||||||
namespace BenchmarkOcc {
|
namespace BenchmarkOcc {
|
||||||
|
|
@ -13,40 +13,40 @@
|
|||||||
** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "bench_tools.h"
|
#include "benchmark_tools.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# define BENCH_TIMER_WINDOWS
|
# define BENCHMARK_TIMER_WINDOWS
|
||||||
#else
|
#else
|
||||||
# define BENCH_TIMER_LIBC
|
# define BENCHMARK_TIMER_LIBC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct bench_timer
|
typedef struct benchmark_timer
|
||||||
{
|
{
|
||||||
#ifdef BENCH_TIMER_WINDOWS
|
#ifdef BENCHMARK_TIMER_WINDOWS
|
||||||
LARGE_INTEGER start_time;
|
LARGE_INTEGER start_time;
|
||||||
LARGE_INTEGER frequency;
|
LARGE_INTEGER frequency;
|
||||||
#elif defined(BENCH_TIMER_LIBC)
|
#elif defined(BENCHMARK_TIMER_LIBC)
|
||||||
clock_t start_tick;
|
clock_t start_tick;
|
||||||
#endif
|
#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);
|
QueryPerformanceFrequency(&timer->frequency);
|
||||||
QueryPerformanceCounter(&timer->start_time);
|
QueryPerformanceCounter(&timer->start_time);
|
||||||
#elif defined(BENCH_TIMER_LIBC)
|
#elif defined(BENCHMARK_TIMER_LIBC)
|
||||||
timer->start_tick = clock();
|
timer->start_tick = clock();
|
||||||
#endif
|
#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 end_time = { 0 };
|
||||||
LARGE_INTEGER elapsed = { 0 };
|
LARGE_INTEGER elapsed = { 0 };
|
||||||
QueryPerformanceCounter(&end_time);
|
QueryPerformanceCounter(&end_time);
|
||||||
@ -63,7 +63,7 @@ int64_t bench_timer_elapsed_ms(const bench_timer_t* timer)
|
|||||||
elapsed.QuadPart *= 1000;
|
elapsed.QuadPart *= 1000;
|
||||||
elapsed.QuadPart /= timer->frequency.QuadPart;
|
elapsed.QuadPart /= timer->frequency.QuadPart;
|
||||||
return elapsed.QuadPart;
|
return elapsed.QuadPart;
|
||||||
#elif defined(BENCH_TIMER_LIBC)
|
#elif defined(BENCHMARK_TIMER_LIBC)
|
||||||
/* For seconds:
|
/* For seconds:
|
||||||
* return (float)((clock() - start_tick) / (float)CLOCKS_PER_SEC); */
|
* return (float)((clock() - start_tick) / (float)CLOCKS_PER_SEC); */
|
||||||
return clock() - timer->start_tick;
|
return clock() - timer->start_tick;
|
||||||
@ -71,15 +71,15 @@ int64_t bench_timer_elapsed_ms(const bench_timer_t* timer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void benchmark_list(
|
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;
|
int iarg;
|
||||||
|
|
||||||
if (func == NULL)
|
if (func == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bench_timer_start(&timer);
|
benchmark_timer_start(&timer);
|
||||||
|
|
||||||
printf("Bench %s ...\n", title);
|
printf("Bench %s ...\n", title);
|
||||||
for (iarg = 0; iarg < argc; ++iarg) {
|
for (iarg = 0; iarg < argc; ++iarg) {
|
||||||
@ -87,10 +87,10 @@ void benchmark_list(
|
|||||||
(*func)(argv[iarg]);
|
(*func)(argv[iarg]);
|
||||||
}
|
}
|
||||||
/*printf(" exec time: %.2fs\n\n", elapsed_secs(start_tick));*/
|
/*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;
|
int i = 0;
|
||||||
while (i < argc) {
|
while (i < argc) {
|
||||||
@ -100,7 +100,7 @@ void benchmark_forward_list(bench_file_func_t func, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void benchmark(
|
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);
|
benchmark_list(func, title, 1, (char**)&filepath);
|
||||||
}
|
}
|
@ -13,24 +13,24 @@
|
|||||||
** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef BENCH_TOOLS_H
|
#ifndef BENCHMARK_TOOLS_H
|
||||||
#define BENCH_TOOLS_H
|
#define BENCHMARK_TOOLS_H
|
||||||
|
|
||||||
#include <gmio_core/global.h>
|
#include <gmio_core/global.h>
|
||||||
|
|
||||||
GMIO_C_LINKAGE_BEGIN
|
GMIO_C_LINKAGE_BEGIN
|
||||||
|
|
||||||
typedef void (*bench_file_func_t)(const char*);
|
typedef void (*benchmark_file_func_t)(const char*);
|
||||||
|
|
||||||
void benchmark_list(
|
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(
|
void benchmark_forward_list(
|
||||||
bench_file_func_t func, int argc, char** argv);
|
benchmark_file_func_t func, int argc, char** argv);
|
||||||
|
|
||||||
void benchmark(
|
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
|
GMIO_C_LINKAGE_END
|
||||||
|
|
||||||
#endif /* BENCH_TOOLS_H */
|
#endif /* BENCHMARK_TOOLS_H */
|
Loading…
Reference in New Issue
Block a user