mirror of
https://github.com/BlackMATov/flat.hpp.git
synced 2025-12-15 02:12:23 +07:00
add dummy benchmark project
This commit is contained in:
@@ -10,9 +10,14 @@ project(flat.hpp)
|
|||||||
add_library(${PROJECT_NAME} INTERFACE)
|
add_library(${PROJECT_NAME} INTERFACE)
|
||||||
target_include_directories(${PROJECT_NAME} INTERFACE headers)
|
target_include_directories(${PROJECT_NAME} INTERFACE headers)
|
||||||
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_14)
|
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_14)
|
||||||
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
|
||||||
|
|
||||||
if(BUILD_AS_STANDALONE)
|
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)
|
option(BUILD_WITH_UNTESTS "Build with unit tests" ON)
|
||||||
if(BUILD_WITH_UNTESTS)
|
if(BUILD_WITH_UNTESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|||||||
24
unbench/CMakeLists.txt
Normal file
24
unbench/CMakeLists.txt
Normal 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})
|
||||||
21
unbench/flat_map_bench.cpp
Normal file
21
unbench/flat_map_bench.cpp
Normal 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);
|
||||||
21
unbench/flat_set_bench.cpp
Normal file
21
unbench/flat_set_bench.cpp
Normal 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);
|
||||||
@@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
|
|||||||
|
|
||||||
project(flat.hpp.untests)
|
project(flat.hpp.untests)
|
||||||
|
|
||||||
|
set(CATCH_BUILD_TESTING OFF CACHE BOOL "" FORCE)
|
||||||
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
catch2
|
catch2
|
||||||
@@ -17,6 +19,6 @@ endif()
|
|||||||
file(GLOB UNTESTS_SOURCES "*.cpp" "*.hpp")
|
file(GLOB UNTESTS_SOURCES "*.cpp" "*.hpp")
|
||||||
add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES})
|
add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES})
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
Catch2::Catch2
|
Catch2
|
||||||
flat.hpp::flat.hpp)
|
flat.hpp)
|
||||||
add_test(${PROJECT_NAME} ${PROJECT_NAME})
|
add_test(${PROJECT_NAME} ${PROJECT_NAME})
|
||||||
|
|||||||
Reference in New Issue
Block a user