Commit 199c7fdf authored by Kirk Shoop's avatar Kirk Shoop Committed by Facebook Github Bot

add benchmarks and options for compiler flags (#29)

fbshipit-source-id: 6b132d537fa3cb5c9448b1c7d2adcc6204682f47
parent bd571274
...@@ -3,7 +3,11 @@ cmake_minimum_required(VERSION 3.7) ...@@ -3,7 +3,11 @@ cmake_minimum_required(VERSION 3.7)
project(pushmi-project CXX) project(pushmi-project CXX)
FIND_PACKAGE (Threads) option(PUSHMI_USE_CONCEPTS_EMULATION "Use C++14 Concepts Emulation" ON)
option(PUSHMI_USE_CPP_2A "Use C++2a with concepts emulation" OFF)
option(PUSHMI_USE_CPP_17 "Use C++17 with concepts emulation" OFF)
FIND_PACKAGE (Threads REQUIRED)
add_library(pushmi INTERFACE) add_library(pushmi INTERFACE)
...@@ -13,15 +17,57 @@ target_include_directories(pushmi INTERFACE ...@@ -13,15 +17,57 @@ target_include_directories(pushmi INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/futures-impl/future-executor-interaction/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/futures-impl/future-executor-interaction/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/networking-ts-impl/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/networking-ts-impl/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/Catch2/single_include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/Catch2/single_include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/nonius/include>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include> $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/executors> $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/executors>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/futures> $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/futures>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/net> $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/net>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/Catch2>) $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/Catch2>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/nonius>)
if (PUSHMI_USE_CONCEPTS_EMULATION)
message("Using concepts emulation!")
if(${CMAKE_VERSION} VERSION_LESS "3.8.0" OR PUSHMI_USE_CPP_17 OR PUSHMI_USE_CPP_2A)
if (PUSHMI_USE_CPP_17)
message("Using c++17!")
target_compile_options(pushmi INTERFACE
$<$<CXX_COMPILER_ID:GNU>:-std=c++17>
)
elseif (PUSHMI_USE_CPP_2A)
message("Using c++2a!")
target_compile_options(pushmi INTERFACE
$<$<CXX_COMPILER_ID:GNU>:-std=c++2a>
)
else()
message("Using c++14!")
target_compile_options(pushmi INTERFACE
$<$<CXX_COMPILER_ID:GNU>:-std=c++14>
)
endif()
else()
target_compile_features(pushmi INTERFACE cxx_std_14) target_compile_features(pushmi INTERFACE cxx_std_14)
endif()
else(PUSHMI_USE_CONCEPTS_EMULATION)
message("Using real concepts!")
message("Using c++2a!")
target_compile_options(pushmi INTERFACE
$<$<CXX_COMPILER_ID:GNU>:-std=c++2a>
$<$<CXX_COMPILER_ID:GNU>:-fconcepts>)
endif(PUSHMI_USE_CONCEPTS_EMULATION)
target_compile_options(pushmi INTERFACE target_compile_options(pushmi INTERFACE
#$<$<CXX_COMPILER_ID:GNU>:-std=c++2a>
#$<$<CXX_COMPILER_ID:GNU>:-fconcepts>
$<$<CXX_COMPILER_ID:GNU>:-ftemplate-backtrace-limit=0>) $<$<CXX_COMPILER_ID:GNU>:-ftemplate-backtrace-limit=0>)
add_custom_target(buildSingleHeader COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/buildSingleHeader.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) add_custom_target(buildSingleHeader COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/buildSingleHeader.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
...@@ -42,11 +88,16 @@ install( ...@@ -42,11 +88,16 @@ install(
install( install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/external/Catch2/ DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/external/Catch2/
DESTINATION include/Catch2) DESTINATION include/Catch2)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/external/nonius/include/
DESTINATION include/nonius)
install(TARGETS pushmi EXPORT pushmi-project) install(TARGETS pushmi EXPORT pushmi-project)
install(EXPORT pushmi-project DESTINATION pushmi-project) install(EXPORT pushmi-project DESTINATION pushmi-project)
add_subdirectory(examples) add_subdirectory(examples)
add_subdirectory(benchmarks)
enable_testing() enable_testing()
include(CTest) include(CTest)
add_subdirectory(test) add_subdirectory(test)
FIND_PACKAGE (Boost)
if (Boost_FOUND)
add_executable(PushmiBenchmarks
runner.cpp
PushmiBenchmarks.cpp
)
target_include_directories(PushmiBenchmarks
PUBLIC ${Boost_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/../examples/include
)
target_link_libraries(PushmiBenchmarks
pushmi
Threads::Threads
${Boost_LIBRARIES}
)
else()
message(WARNING "Boost not found, no benchmarks will be built")
endif()
#include "pushmi/o/just.h"
#include "pushmi/o/on.h"
#include "pushmi/o/transform.h"
#include "pushmi/o/tap.h"
#include "pushmi/o/via.h"
#include "pushmi/o/submit.h"
#include "pushmi/trampoline.h"
#include "pushmi/new_thread.h"
#include "pool.h"
using namespace pushmi::aliases;
struct countdownsingle {
countdownsingle(int& c)
: counter(&c) {}
int* counter;
template <class ExecutorRef>
void operator()(ExecutorRef exec) {
if (--*counter > 0) {
exec | op::submit(*this);
}
}
};
#define concept Concept
#include <nonius/nonius.h++>
NONIUS_BENCHMARK("trampoline virtual derecursion 10,000", [](nonius::chronometer meter){
int counter = 0;
auto tr = mi::trampoline();
using TR = decltype(tr);
std::function<void(mi::any_time_executor_ref<> exec)> recurse;
recurse = [&](mi::any_time_executor_ref<> tr) {
if (--counter <= 0)
return;
tr | op::submit(recurse);
};
meter.measure([&]{
counter = 10'000;
return tr | op::submit([&](auto exec) { recurse(exec); });
});
})
NONIUS_BENCHMARK("trampoline static derecursion 10,000", [](nonius::chronometer meter){
int counter = 0;
auto tr = mi::trampoline();
using TR = decltype(tr);
countdownsingle single{counter};
meter.measure([&]{
counter = 10'000;
return tr | op::submit(single);
});
})
NONIUS_BENCHMARK("new thread 10 blocking_submits", [](nonius::chronometer meter){
auto nt = mi::new_thread();
using NT = decltype(nt);
meter.measure([&]{
return nt |
op::blocking_submit() |
op::blocking_submit() |
op::blocking_submit() |
op::blocking_submit() |
op::blocking_submit() |
op::blocking_submit() |
op::blocking_submit() |
op::blocking_submit() |
op::blocking_submit() |
op::transform([](auto nt){
return v::now(nt);
}) |
op::get<std::chrono::system_clock::time_point>;
});
})
NONIUS_BENCHMARK("pool 10 blocking_submits", [](nonius::chronometer meter){
mi::pool pl{std::max(1u,std::thread::hardware_concurrency())};
auto pe = pl.executor();
using PE = decltype(pe);
meter.measure([&]{
return pe |
op::blocking_submit() |
op::blocking_submit() |
op::blocking_submit() |
op::blocking_submit() |
op::blocking_submit() |
op::blocking_submit() |
op::blocking_submit() |
op::blocking_submit() |
op::blocking_submit() |
op::transform([](auto pe){
return mi::now(pe);
}) |
op::get<std::chrono::system_clock::time_point>;
});
})
#define NONIUS_RUNNER
#define concept Concept
#include <nonius/nonius.h++>
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment