C++11: Laid foundation for benchmark tests. We need more of them!
This commit is contained in:
11
src/Benchmark/CMakeLists.txt
Normal file
11
src/Benchmark/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
set (SOURCES "")
|
||||
list (APPEND SOURCES
|
||||
main.cpp
|
||||
VectorT_new.cpp
|
||||
VectorT_legacy.cpp
|
||||
)
|
||||
|
||||
add_executable(OMBenchmark ${SOURCES})
|
||||
set_target_properties(OMBenchmark PROPERTIES
|
||||
INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
target_link_libraries(OMBenchmark benchmark OpenMeshCore)
|
||||
29
src/Benchmark/VectorT.cpp
Normal file
29
src/Benchmark/VectorT.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* VectorT.cpp
|
||||
*
|
||||
* Created on: Nov 19, 2015
|
||||
* Author: ebke
|
||||
*/
|
||||
|
||||
#ifndef BMPREFIX
|
||||
#error "Do not compile directly."
|
||||
#endif
|
||||
|
||||
#define ASSEMBLE_(PREFIX, SUFFIX) PREFIX ## SUFFIX
|
||||
#define ASSEMBLE(PREFIX, SUFFIX) ASSEMBLE_(PREFIX, SUFFIX)
|
||||
#define MYBENCHMARK(NAME) BENCHMARK(NAME)
|
||||
|
||||
static void ASSEMBLE(BMPREFIX, Vec3f_add_compare)(benchmark::State& state) {
|
||||
OpenMesh::Vec3f v1(0, 0, 0);
|
||||
OpenMesh::Vec3f v2(1000, 1000, 1000);
|
||||
while (state.KeepRunning()) {
|
||||
v1 += OpenMesh::Vec3f(1.1, 1.2, 1.3);
|
||||
v2 -= OpenMesh::Vec3f(1.1, 1.2, 1.3);
|
||||
if (v1 == v2) {
|
||||
v1 -= v2;
|
||||
v2 += v1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MYBENCHMARK (ASSEMBLE(BMPREFIX, Vec3f_add_compare));
|
||||
14
src/Benchmark/VectorT_legacy.cpp
Normal file
14
src/Benchmark/VectorT_legacy.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* VectorT_legacy.cpp
|
||||
*
|
||||
* Created on: Nov 19, 2015
|
||||
* Author: ebke
|
||||
*/
|
||||
|
||||
#include <benchmark/benchmark_api.h>
|
||||
|
||||
#define OPENMESH_VECTOR_LEGACY
|
||||
#include <OpenMesh/Core/Geometry/VectorT.hh>
|
||||
|
||||
#define BMPREFIX Legacy_
|
||||
#include "VectorT.cpp"
|
||||
12
src/Benchmark/VectorT_new.cpp
Normal file
12
src/Benchmark/VectorT_new.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* VectorT_new.cpp
|
||||
*
|
||||
* Created on: Nov 19, 2015
|
||||
* Author: ebke
|
||||
*/
|
||||
|
||||
#include <benchmark/benchmark_api.h>
|
||||
#include <OpenMesh/Core/Geometry/VectorT.hh>
|
||||
|
||||
#define BMPREFIX CPP11_
|
||||
#include "VectorT.cpp"
|
||||
10
src/Benchmark/main.cpp
Normal file
10
src/Benchmark/main.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* main.cpp
|
||||
*
|
||||
* Created on: Nov 19, 2015
|
||||
* Author: ebke
|
||||
*/
|
||||
|
||||
#include <benchmark/benchmark_api.h>
|
||||
|
||||
BENCHMARK_MAIN();
|
||||
Reference in New Issue
Block a user