add dummy benchmark project

This commit is contained in:
2019-05-07 03:10:20 +07:00
parent 06d4916d46
commit 073789c767
5 changed files with 76 additions and 3 deletions

View File

@@ -10,9 +10,14 @@ project(flat.hpp)
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE headers)
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_14)
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
if(BUILD_AS_STANDALONE)
option(BUILD_WITH_UNBENCH "Build with benchmarks" OFF)
if(BUILD_WITH_UNBENCH)
enable_testing()
add_subdirectory(unbench)
endif()
option(BUILD_WITH_UNTESTS "Build with unit tests" ON)
if(BUILD_WITH_UNTESTS)
enable_testing()

24
unbench/CMakeLists.txt Normal file
View File

@@ -0,0 +1,24 @@
# 3.11 version is required for `FetchContent`
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
project(flat.hpp.unbench)
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
include(FetchContent)
FetchContent_Declare(
gbench
GIT_REPOSITORY https://github.com/google/benchmark)
FetchContent_GetProperties(gbench)
if(NOT gbench_POPULATED)
FetchContent_Populate(gbench)
add_subdirectory(${gbench_SOURCE_DIR} ${gbench_BINARY_DIR})
endif()
file(GLOB UNBENCH_SOURCES "*.cpp" "*.hpp")
add_executable(${PROJECT_NAME} ${UNBENCH_SOURCES})
target_link_libraries(${PROJECT_NAME}
benchmark_main
flat.hpp)
add_test(${PROJECT_NAME} ${PROJECT_NAME})

View File

@@ -0,0 +1,21 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <benchmark/benchmark.h>
#include <flat_hpp/flat_map.hpp>
using namespace flat_hpp;
namespace
{
void flat_map_default_ctor(benchmark::State& state) {
for ( auto _ : state ) {
flat_map<int, unsigned> s0;
}
}
}
BENCHMARK(flat_map_default_ctor);

View File

@@ -0,0 +1,21 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <benchmark/benchmark.h>
#include <flat_hpp/flat_set.hpp>
using namespace flat_hpp;
namespace
{
void flat_set_default_ctor(benchmark::State& state) {
for ( auto _ : state ) {
flat_set<int> s0;
}
}
}
BENCHMARK(flat_set_default_ctor);

View File

@@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
project(flat.hpp.untests)
set(CATCH_BUILD_TESTING OFF CACHE BOOL "" FORCE)
include(FetchContent)
FetchContent_Declare(
catch2
@@ -17,6 +19,6 @@ endif()
file(GLOB UNTESTS_SOURCES "*.cpp" "*.hpp")
add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES})
target_link_libraries(${PROJECT_NAME}
Catch2::Catch2
flat.hpp::flat.hpp)
Catch2
flat.hpp)
add_test(${PROJECT_NAME} ${PROJECT_NAME})