diff --git a/CMakeLists.txt b/CMakeLists.txt
index 386cc725..a95f9bef 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,3 @@
-
cmake_minimum_required(VERSION 3.5.1)
cmake_policy(SET CMP0048 NEW) # enable project VERSION
cmake_policy(SET CMP0056 NEW) # honor link flags in try_compile()
@@ -6,20 +5,22 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
project(immer VERSION 0.8.0)
-if (NOT MSVC)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wno-unused-parameter -Wno-extended-offsetof -Wno-c++17-extensions -Wno-c++1z-extensions -Wno-unknown-warning-option -Wno-type-limits")
+if(NOT MSVC)
+ set(CMAKE_CXX_FLAGS
+ "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wno-unused-parameter -Wno-extended-offsetof -Wno-c++17-extensions -Wno-c++1z-extensions -Wno-unknown-warning-option -Wno-type-limits"
+ )
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS on)
set(CMAKE_CXX_EXTENSIONS off)
-if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
endif()
include(GNUInstallDirs)
include(ImmerUtils)
-# Options
-# =======
+# Options
+# =======
option(ENABLE_ASAN "compile with address sanitizer enabled")
option(ENABLE_MSAN "compile with memory sanitizer enabled")
@@ -36,37 +37,40 @@ option(ENABLE_GUILE "enable building guile module" off)
option(ENABLE_BOOST_COROUTINE "run benchmarks with boost coroutine" off)
option(immer_BUILD_TESTS "Build tests" ON)
+option(immer_BUILD_PERSIST_TESTS "Build experimental persist tests" off)
option(immer_BUILD_EXAMPLES "Build examples" ON)
option(immer_BUILD_DOCS "Build docs" ON)
option(immer_BUILD_EXTRAS "Build extras" ON)
option(immer_INSTALL_FUZZERS "Install fuzzers" off)
-set(CXX_STANDARD 14 CACHE STRING "c++ standard number")
+set(CXX_STANDARD
+ 14
+ CACHE STRING "c++ standard number")
set(CMAKE_CXX_STANDARD ${CXX_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED on)
-if (ENABLE_ASAN)
+if(ENABLE_ASAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
endif()
-if (ENABLE_LSAN)
+if(ENABLE_LSAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak")
endif()
-if (ENABLE_UBSAN)
+if(ENABLE_UBSAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
endif()
-if (ENABLE_MSAN)
+if(ENABLE_MSAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory")
endif()
-if (NOT MSVC AND NOT DISABLE_WERROR)
+if(NOT MSVC AND NOT DISABLE_WERROR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()
-# Dependencies
-# ============
+# Dependencies
+# ============
-if (ENABLE_BOOST_COROUTINE)
+if(ENABLE_BOOST_COROUTINE)
set(immer_boost_components coroutine)
endif()
@@ -75,7 +79,7 @@ find_package(BoehmGC)
find_package(Boost 1.56 COMPONENTS ${immer_boost_components})
find_program(CCACHE ccache)
-if (CCACHE)
+if(CCACHE)
message(STATUS "Using ccache: ${CCACHE}")
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE})
set(CMAKE_CXX_LINKER_LAUNCHER ${CCACHE})
@@ -83,19 +87,20 @@ else()
message(STATUS "Could not find ccache")
endif()
-if (NOT BOEHM_GC_FOUND)
+if(NOT BOEHM_GC_FOUND)
set(BOEHM_GC_LIBRARIES "")
endif()
-# Targets
-# =======
+# Targets
+# =======
# the library
add_library(immer INTERFACE)
-target_include_directories(immer INTERFACE
- $
- $
- $)
+target_include_directories(
+ immer
+ INTERFACE $
+ $
+ $)
install(TARGETS immer EXPORT ImmerConfig)
install(EXPORT ImmerConfig DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Immer")
install(DIRECTORY immer DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
@@ -104,62 +109,62 @@ include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/ImmerConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
- COMPATIBILITY SameMajorVersion )
+ COMPATIBILITY SameMajorVersion)
-install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ImmerConfigVersion.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Immer" )
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ImmerConfigVersion.cmake"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Immer")
# development target to be used in tests, examples, benchmarks...
-immer_canonicalize_cmake_booleans(
- DISABLE_FREE_LIST
- DISABLE_THREAD_SAFETY
- CHECK_SLOW_TESTS)
+immer_canonicalize_cmake_booleans(DISABLE_FREE_LIST DISABLE_THREAD_SAFETY
+ CHECK_SLOW_TESTS)
add_library(immer-dev INTERFACE)
-target_include_directories(immer-dev SYSTEM INTERFACE
- ${Boost_INCLUDE_DIR}
- ${BOEHM_GC_INCLUDE_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}/tools/include)
-target_link_libraries(immer-dev INTERFACE
- immer
- ${BOEHM_GC_LIBRARIES}
- ${CMAKE_THREAD_LIBS_INIT})
-target_compile_definitions(immer-dev INTERFACE
- -DIMMER_CXX_STANDARD=${CXX_STANDARD}
- -DIMMER_HAS_LIBGC=1
- -DIMMER_NO_FREE_LIST=${DISABLE_FREE_LIST}
- -DIMMER_NO_THREAD_SAFETY=${DISABLE_THREAD_SAFETY}
- -DIMMER_SLOW_TESTS=${CHECK_SLOW_TESTS}
- -DFMT_HEADER_ONLY=1)
-if (ENABLE_COVERAGE)
+target_include_directories(
+ immer-dev SYSTEM INTERFACE ${Boost_INCLUDE_DIR} ${BOEHM_GC_INCLUDE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/tools/include)
+target_link_libraries(immer-dev INTERFACE immer ${BOEHM_GC_LIBRARIES}
+ ${CMAKE_THREAD_LIBS_INIT})
+target_compile_definitions(
+ immer-dev
+ INTERFACE -DIMMER_CXX_STANDARD=${CXX_STANDARD}
+ -DIMMER_HAS_LIBGC=1
+ -DIMMER_NO_FREE_LIST=${DISABLE_FREE_LIST}
+ -DIMMER_NO_THREAD_SAFETY=${DISABLE_THREAD_SAFETY}
+ -DIMMER_SLOW_TESTS=${CHECK_SLOW_TESTS}
+ -DFMT_HEADER_ONLY=1)
+if(ENABLE_COVERAGE)
target_compile_options(immer-dev INTERFACE "--coverage")
target_link_libraries(immer-dev INTERFACE "--coverage")
endif()
-# Testing
-# =======
+# Testing
+# =======
-if (immer_BUILD_TESTS OR immer_BUILD_EXAMPLES OR immer_BUILD_EXTRAS)
- add_custom_target(check
- COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- COMMENT "Build and run all the tests and examples.")
+if(immer_BUILD_TESTS
+ OR immer_BUILD_EXAMPLES
+ OR immer_BUILD_EXTRAS)
+ add_custom_target(
+ check
+ COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ COMMENT "Build and run all the tests and examples.")
endif()
-if (immer_BUILD_TESTS)
+if(immer_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
add_subdirectory(benchmark)
endif()
-if (immer_BUILD_EXAMPLES)
+if(immer_BUILD_EXAMPLES)
add_subdirectory(example)
endif()
-if (immer_BUILD_DOCS)
+if(immer_BUILD_DOCS)
add_subdirectory(doc)
endif()
-if (immer_BUILD_EXTRAS)
+if(immer_BUILD_EXTRAS)
add_subdirectory(extra/fuzzer)
add_subdirectory(extra/python)
add_subdirectory(extra/guile)
diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt
index 861157c5..2dac325d 100644
--- a/benchmark/CMakeLists.txt
+++ b/benchmark/CMakeLists.txt
@@ -1,35 +1,37 @@
-
-# Config
-# ======
+# Config
+# ======
option(CHECK_BENCHMARKS "Run benchmarks on check target" off)
option(BENCHMARK_DISABLE_GC "Disable gc during a measurement")
-set(BENCHMARK_PARAM "N:1000" CACHE STRING "Benchmark parameters")
-set(BENCHMARK_SAMPLES "20" CACHE STRING "Benchmark samples")
+set(BENCHMARK_PARAM
+ "N:1000"
+ CACHE STRING "Benchmark parameters")
+set(BENCHMARK_SAMPLES
+ "20"
+ CACHE STRING "Benchmark samples")
-# Dependencies
-# ============
+# Dependencies
+# ============
find_package(RRB)
-if (NOT RRB_FOUND)
+if(NOT RRB_FOUND)
message(STATUS "Disabling benchmarks")
return()
endif()
-# These are expected to be in the include path, the nix-shell
-# environment installs them:
+# These are expected to be in the include path, the nix-shell environment
+# installs them:
#
-# https://github.com/marcusz/steady
-# https://github.com/deepsea-inria/chunkedseq.git
-# https://github.com/rsms/immutable-cpp.git
+# https://github.com/marcusz/steady
+# https://github.com/deepsea-inria/chunkedseq.git
+# https://github.com/rsms/immutable-cpp.git
-# Targets
-# =======
+# Targets
+# =======
-add_custom_target(benchmarks
- COMMENT "Build all benchmarks.")
+add_custom_target(benchmarks COMMENT "Build all benchmarks.")
execute_process(
COMMAND git log -1 --format=%h
@@ -43,7 +45,7 @@ execute_process(
OUTPUT_VARIABLE immer_git_status
OUTPUT_STRIP_TRAILING_WHITESPACE)
-if (NOT immer_git_status STREQUAL "")
+if(NOT immer_git_status STREQUAL "")
set(immer_git_commit_hash "${immer_git_commit_hash}+")
endif()
@@ -52,7 +54,8 @@ site_name(immer_hostname)
get_filename_component(immer_compiler_name "${CMAKE_CXX_COMPILER}" NAME)
set(immer_benchmark_report_base_dir "${CMAKE_SOURCE_DIR}/reports")
-set(immer_benchmark_report_dir "${immer_benchmark_report_base_dir}/report_\
+set(immer_benchmark_report_dir
+ "${immer_benchmark_report_base_dir}/report_\
${immer_git_commit_hash}_\
${immer_hostname}_\
${immer_compiler_name}_\
@@ -75,9 +78,9 @@ if(CHECK_BENCHMARKS)
add_dependencies(check benchmarks)
endif()
-add_custom_target(benchmark-report-dir
- COMMAND ${CMAKE_COMMAND}
- -E make_directory ${immer_benchmark_report_dir})
+add_custom_target(
+ benchmark-report-dir COMMAND ${CMAKE_COMMAND} -E make_directory
+ ${immer_benchmark_report_dir})
file(GLOB_RECURSE immer_benchmarks "*.cpp")
foreach(_file IN LISTS immer_benchmarks)
@@ -87,36 +90,41 @@ foreach(_file IN LISTS immer_benchmarks)
add_dependencies(benchmarks ${_target})
add_dependencies(${_target} benchmark-report-dir)
target_compile_options(${_target} PUBLIC -Wno-unused-function)
- target_compile_definitions(${_target} PUBLIC
- NONIUS_RUNNER
- IMMER_BENCHMARK_LIBRRB=1
- IMMER_BENCHMARK_STEADY=1
- IMMER_BENCHMARK_EXPERIMENTAL=0
- IMMER_BENCHMARK_DISABLE_GC=${BENCHMARK_DISABLE_GC}
- IMMER_BENCHMARK_BOOST_COROUTINE=${ENABLE_BOOST_COROUTINE})
- target_link_libraries(${_target} PUBLIC
- immer-dev
- ${RRB_LIBRARIES})
- target_include_directories(${_target} SYSTEM PUBLIC
- ${RRB_INCLUDE_DIR})
+ target_compile_definitions(
+ ${_target}
+ PUBLIC NONIUS_RUNNER
+ IMMER_BENCHMARK_LIBRRB=1
+ IMMER_BENCHMARK_STEADY=1
+ IMMER_BENCHMARK_EXPERIMENTAL=0
+ IMMER_BENCHMARK_DISABLE_GC=${BENCHMARK_DISABLE_GC}
+ IMMER_BENCHMARK_BOOST_COROUTINE=${ENABLE_BOOST_COROUTINE})
+ target_link_libraries(${_target} PUBLIC immer-dev ${RRB_LIBRARIES})
+ target_include_directories(${_target} SYSTEM PUBLIC ${RRB_INCLUDE_DIR})
if(CHECK_BENCHMARKS)
- add_test("benchmark/${_output}" "${CMAKE_SOURCE_DIR}/tools/with-tee.bash"
+ add_test(
+ "benchmark/${_output}"
+ "${CMAKE_SOURCE_DIR}/tools/with-tee.bash"
${immer_benchmark_report_dir}/${_target}.out
- "${CMAKE_CURRENT_BINARY_DIR}/${_output}" -v
- -t ${_target}
- -r html
- -s ${BENCHMARK_SAMPLES}
- -p ${BENCHMARK_PARAM}
- -o ${immer_benchmark_report_dir}/${_target}.html)
+ "${CMAKE_CURRENT_BINARY_DIR}/${_output}"
+ -v
+ -t
+ ${_target}
+ -r
+ html
+ -s
+ ${BENCHMARK_SAMPLES}
+ -p
+ ${BENCHMARK_PARAM}
+ -o
+ ${immer_benchmark_report_dir}/${_target}.html)
endif()
endforeach()
-add_custom_target(upload-benchmark-reports
- COMMAND
- rsync -av ${immer_benchmark_report_base_dir}
- root@sinusoid.es:/var/lib/syncthing/public/misc/immer/)
+add_custom_target(
+ upload-benchmark-reports
+ COMMAND rsync -av ${immer_benchmark_report_base_dir}
+ root@sinusoid.es:/var/lib/syncthing/public/misc/immer/)
-add_custom_target(copy-benchmark-reports
- COMMAND
- rsync -av ${immer_benchmark_report_base_dir}
- ~/public/misc/immer/)
+add_custom_target(
+ copy-benchmark-reports COMMAND rsync -av ${immer_benchmark_report_base_dir}
+ ~/public/misc/immer/)
diff --git a/benchmark/extra/refcounting.cpp b/benchmark/extra/refcounting.cpp
index c7c5183e..aeee3f60 100644
--- a/benchmark/extra/refcounting.cpp
+++ b/benchmark/extra/refcounting.cpp
@@ -8,15 +8,15 @@
#include
-#include
#include
+#include
+#include
#include
#include
#include
#include
#include
-#include
#include
NONIUS_PARAM(N, std::size_t{1000})
@@ -29,64 +29,55 @@ struct object_t : immer::detail::ref_count_base
auto make_data()
{
auto objs = std::array, benchmark_size>();
- std::generate(objs.begin(), objs.end(), [] {
- return std::make_unique();
- });
+ std::generate(
+ objs.begin(), objs.end(), [] { return std::make_unique(); });
auto refs = std::array();
std::transform(objs.begin(), objs.end(), refs.begin(), [](auto& obj) {
return obj.get();
});
- return make_pair(std::move(objs),
- std::move(refs));
+ return make_pair(std::move(objs), std::move(refs));
}
-NONIUS_BENCHMARK("intrusive_ptr", [] (nonius::chronometer meter)
-{
+NONIUS_BENCHMARK("intrusive_ptr", [](nonius::chronometer meter) {
auto arr = std::array, benchmark_size>{};
- auto storage = std::vector<
- nonius::storage_for<
- std::array, benchmark_size>>> (
- meter.runs());
- std::generate(arr.begin(), arr.end(), [] {
- return new object_t{};
- });
- meter.measure([&] (int i) {
- storage[i].construct(arr);
- });
+ auto storage = std::vector, benchmark_size>>>(
+ meter.runs());
+ std::generate(arr.begin(), arr.end(), [] { return new object_t{}; });
+ meter.measure([&](int i) { storage[i].construct(arr); });
})
-NONIUS_BENCHMARK("generic", [] (nonius::chronometer meter)
-{
- auto data = make_data();
+NONIUS_BENCHMARK("generic", [](nonius::chronometer meter) {
+ auto data = make_data();
auto& refs = data.second;
object_t* r[benchmark_size];
meter.measure([&] {
- std::transform(refs.begin(), refs.end(), r, [] (auto& p) {
- if (p) p->ref_count.fetch_add(1, std::memory_order_relaxed);
+ std::transform(refs.begin(), refs.end(), r, [](auto& p) {
+ if (p)
+ p->ref_count.fetch_add(1, std::memory_order_relaxed);
return p;
});
return r;
});
})
-NONIUS_BENCHMARK("manual", [] (nonius::chronometer meter)
-{
- auto data = make_data();
+NONIUS_BENCHMARK("manual", [](nonius::chronometer meter) {
+ auto data = make_data();
auto& refs = data.second;
object_t* r[benchmark_size];
meter.measure([&] {
for (auto& p : refs)
- if (p) p->ref_count.fetch_add(1, std::memory_order_relaxed);
+ if (p)
+ p->ref_count.fetch_add(1, std::memory_order_relaxed);
std::copy(refs.begin(), refs.end(), r);
return r;
});
})
-NONIUS_BENCHMARK("manual - unroll", [] (nonius::chronometer meter)
-{
- auto data = make_data();
+NONIUS_BENCHMARK("manual - unroll", [](nonius::chronometer meter) {
+ auto data = make_data();
auto& refs = data.second;
object_t* r[benchmark_size];
@@ -103,9 +94,8 @@ NONIUS_BENCHMARK("manual - unroll", [] (nonius::chronometer meter)
});
})
-NONIUS_BENCHMARK("manual - nocheck", [] (nonius::chronometer meter)
-{
- auto data = make_data();
+NONIUS_BENCHMARK("manual - nocheck", [](nonius::chronometer meter) {
+ auto data = make_data();
auto& refs = data.second;
object_t* r[benchmark_size];
@@ -117,9 +107,8 @@ NONIUS_BENCHMARK("manual - nocheck", [] (nonius::chronometer meter)
});
})
-NONIUS_BENCHMARK("manual - constant", [] (nonius::chronometer meter)
-{
- auto data = make_data();
+NONIUS_BENCHMARK("manual - constant", [](nonius::chronometer meter) {
+ auto data = make_data();
auto& refs = data.second;
object_t* r[benchmark_size];
@@ -131,15 +120,15 @@ NONIUS_BENCHMARK("manual - constant", [] (nonius::chronometer meter)
});
})
-NONIUS_BENCHMARK("manual - memcopy", [] (nonius::chronometer meter)
-{
- auto data = make_data();
+NONIUS_BENCHMARK("manual - memcopy", [](nonius::chronometer meter) {
+ auto data = make_data();
auto& refs = data.second;
object_t* r[benchmark_size];
meter.measure([&] {
for (auto& p : refs)
- if (p) p->ref_count.fetch_add(1, std::memory_order_relaxed);
+ if (p)
+ p->ref_count.fetch_add(1, std::memory_order_relaxed);
std::memcpy(r, &refs[0], sizeof(object_t*) * benchmark_size);
return r;
});
diff --git a/benchmark/set/access.hpp b/benchmark/set/access.hpp
index 8605c0ff..a4efc044 100644
--- a/benchmark/set/access.hpp
+++ b/benchmark/set/access.hpp
@@ -10,21 +10,21 @@
#include "benchmark/config.hpp"
-#include
-#include // Phil Nash
#include
+#include // Phil Nash
+#include
#include
#include
namespace {
-template
+template
auto make_generator_ranged(std::size_t runs)
{
assert(runs > 0);
auto engine = std::default_random_engine{13};
- auto dist = std::uniform_int_distribution{0, (T)runs-1};
- auto r = std::vector(runs);
+ auto dist = std::uniform_int_distribution{0, (T) runs - 1};
+ auto r = std::vector(runs);
std::generate_n(r.begin(), runs, std::bind(dist, engine));
return r;
}
@@ -32,8 +32,7 @@ auto make_generator_ranged(std::size_t runs)
template
auto benchmark_access_std()
{
- return [] (nonius::chronometer meter)
- {
+ return [](nonius::chronometer meter) {
auto n = meter.param();
auto g1 = Generator{}(n);
auto g2 = make_generator_ranged(n);
@@ -55,9 +54,8 @@ auto benchmark_access_std()
template
auto benchmark_access_hamt()
{
- return [] (nonius::chronometer meter)
- {
- auto n = meter.param();
+ return [](nonius::chronometer meter) {
+ auto n = meter.param();
auto g1 = Generator{}(n);
auto g2 = make_generator_ranged(n);
@@ -68,7 +66,7 @@ auto benchmark_access_hamt()
measure(meter, [&] {
auto c = 0u;
for (auto i = 0u; i < n; ++i) {
- auto& x = g1[g2[i]];
+ auto& x = g1[g2[i]];
auto leaf = v.find(x).leaf();
c += !!(leaf && leaf->find(x));
}
@@ -78,13 +76,11 @@ auto benchmark_access_hamt()
};
}
-
template
auto benchmark_access()
{
- return [] (nonius::chronometer meter)
- {
- auto n = meter.param();
+ return [](nonius::chronometer meter) {
+ auto n = meter.param();
auto g1 = Generator{}(n);
auto g2 = make_generator_ranged(n);
@@ -105,10 +101,9 @@ auto benchmark_access()
template
auto benchmark_bad_access_std()
{
- return [] (nonius::chronometer meter)
- {
- auto n = meter.param();
- auto g1 = Generator{}(n*2);
+ return [](nonius::chronometer meter) {
+ auto n = meter.param();
+ auto g1 = Generator{}(n * 2);
auto v = Set{};
for (auto i = 0u; i < n; ++i)
@@ -117,7 +112,7 @@ auto benchmark_bad_access_std()
measure(meter, [&] {
auto c = 0u;
for (auto i = 0u; i < n; ++i)
- c += v.count(g1[n+i]);
+ c += v.count(g1[n + i]);
volatile auto r = c;
return r;
});
@@ -127,10 +122,9 @@ auto benchmark_bad_access_std()
template
auto benchmark_bad_access_hamt()
{
- return [] (nonius::chronometer meter)
- {
- auto n = meter.param();
- auto g1 = Generator{}(n*2);
+ return [](nonius::chronometer meter) {
+ auto n = meter.param();
+ auto g1 = Generator{}(n * 2);
auto v = Set{};
for (auto i = 0u; i < n; ++i)
@@ -139,7 +133,7 @@ auto benchmark_bad_access_hamt()
measure(meter, [&] {
auto c = 0u;
for (auto i = 0u; i < n; ++i) {
- auto& x = g1[n+i];
+ auto& x = g1[n + i];
auto leaf = v.find(x).leaf();
c += !!(leaf && leaf->find(x));
}
@@ -149,14 +143,12 @@ auto benchmark_bad_access_hamt()
};
}
-
template
auto benchmark_bad_access()
{
- return [] (nonius::chronometer meter)
- {
- auto n = meter.param();
- auto g1 = Generator{}(n*2);
+ return [](nonius::chronometer meter) {
+ auto n = meter.param();
+ auto g1 = Generator{}(n * 2);
auto v = Set{};
for (auto i = 0u; i < n; ++i)
@@ -165,7 +157,7 @@ auto benchmark_bad_access()
measure(meter, [&] {
auto c = 0u;
for (auto i = 0u; i < n; ++i)
- c += v.count(g1[n+i]);
+ c += v.count(g1[n + i]);
volatile auto r = c;
return r;
});
diff --git a/benchmark/set/access.ipp b/benchmark/set/access.ipp
index f026d9cf..69740a9e 100644
--- a/benchmark/set/access.ipp
+++ b/benchmark/set/access.ipp
@@ -13,7 +13,9 @@
#endif
using generator__ = GENERATOR_T;
-using t__ = typename decltype(generator__{}(0))::value_type;
+using t__ = typename decltype(generator__{}(0))::value_type;
+
+// clang-format off
NONIUS_BENCHMARK("std::set", benchmark_access_std>())
NONIUS_BENCHMARK("std::unordered_set", benchmark_access_std>())
@@ -28,3 +30,5 @@ NONIUS_BENCHMARK("bad/boost::flat_set", benchmark_bad_access_std>())
NONIUS_BENCHMARK("bad/immer::set/5B", benchmark_bad_access,std::equal_to,def_memory,5>>())
NONIUS_BENCHMARK("bad/immer::set/4B", benchmark_bad_access,std::equal_to,def_memory,4>>())
+
+// clang-format on
diff --git a/benchmark/set/iter.hpp b/benchmark/set/iter.hpp
index 91dd4864..bba4ac66 100644
--- a/benchmark/set/iter.hpp
+++ b/benchmark/set/iter.hpp
@@ -10,30 +10,27 @@
#include "benchmark/config.hpp"
-#include
-#include
-#include
-#include // Phil Nash
#include
+#include // Phil Nash
+#include
+#include
+#include
+#include
#include
#include
-#include
namespace {
template
struct iter_step
{
- unsigned operator() (unsigned x, const T& y) const
- {
- return x + y;
- }
+ unsigned operator()(unsigned x, const T& y) const { return x + y; }
};
template <>
struct iter_step
{
- unsigned operator() (unsigned x, const std::string& y) const
+ unsigned operator()(unsigned x, const std::string& y) const
{
return x + (unsigned) y.size();
}
@@ -42,7 +39,7 @@ struct iter_step
template <>
struct iter_step>
{
- unsigned operator() (unsigned x, const immer::box& y) const
+ unsigned operator()(unsigned x, const immer::box& y) const
{
return x + (unsigned) y->size();
}
@@ -51,8 +48,7 @@ struct iter_step>
template
auto benchmark_access_std_iter()
{
- return [] (nonius::chronometer meter)
- {
+ return [](nonius::chronometer meter) {
auto n = meter.param();
auto g1 = Generator{}(n);
@@ -71,9 +67,8 @@ auto benchmark_access_std_iter()
template
auto benchmark_access_reduce()
{
- return [] (nonius::chronometer meter)
- {
- auto n = meter.param();
+ return [](nonius::chronometer meter) {
+ auto n = meter.param();
auto g1 = Generator{}(n);
auto v = Set{};
@@ -91,9 +86,8 @@ auto benchmark_access_reduce()
template
auto benchmark_access_iter()
{
- return [] (nonius::chronometer meter)
- {
- auto n = meter.param();
+ return [](nonius::chronometer meter) {
+ auto n = meter.param();
auto g1 = Generator{}(n);
auto v = Set{};
diff --git a/benchmark/set/iter.ipp b/benchmark/set/iter.ipp
index f8c3cb96..2c143107 100644
--- a/benchmark/set/iter.ipp
+++ b/benchmark/set/iter.ipp
@@ -13,7 +13,9 @@
#endif
using generator__ = GENERATOR_T;
-using t__ = typename decltype(generator__{}(0))::value_type;
+using t__ = typename decltype(generator__{}(0))::value_type;
+
+// clang-format off
NONIUS_BENCHMARK("iter/std::set", benchmark_access_std_iter>())
NONIUS_BENCHMARK("iter/std::unordered_set", benchmark_access_std_iter>())
@@ -23,3 +25,5 @@ NONIUS_BENCHMARK("iter/immer::set/5B", benchmark_access_iter,std::equal_to,def_memory,4>>())
NONIUS_BENCHMARK("reduce/immer::set/5B", benchmark_access_reduce,std::equal_to,def_memory,5>>())
NONIUS_BENCHMARK("reduce/immer::set/4B", benchmark_access_reduce,std::equal_to,def_memory,4>>())
+
+// clang-format on
diff --git a/benchmark/set/string-box/access.cpp b/benchmark/set/string-box/access.cpp
index c3deffbb..13f87d83 100644
--- a/benchmark/set/string-box/access.cpp
+++ b/benchmark/set/string-box/access.cpp
@@ -7,4 +7,5 @@
//
#include "generator.ipp"
+
#include "../access.ipp"
diff --git a/benchmark/set/string-box/insert.cpp b/benchmark/set/string-box/insert.cpp
index c5762498..7b751877 100644
--- a/benchmark/set/string-box/insert.cpp
+++ b/benchmark/set/string-box/insert.cpp
@@ -8,4 +8,5 @@
#define DISABLE_GC_BENCHMARKS
#include "generator.ipp"
+
#include "../insert.ipp"
diff --git a/benchmark/set/string-box/iter.cpp b/benchmark/set/string-box/iter.cpp
index 83e57e78..48356c38 100644
--- a/benchmark/set/string-box/iter.cpp
+++ b/benchmark/set/string-box/iter.cpp
@@ -7,4 +7,5 @@
//
#include "generator.ipp"
+
#include "../iter.ipp"
diff --git a/benchmark/set/string-long/access.cpp b/benchmark/set/string-long/access.cpp
index c3deffbb..13f87d83 100644
--- a/benchmark/set/string-long/access.cpp
+++ b/benchmark/set/string-long/access.cpp
@@ -7,4 +7,5 @@
//
#include "generator.ipp"
+
#include "../access.ipp"
diff --git a/benchmark/set/string-long/insert.cpp b/benchmark/set/string-long/insert.cpp
index c5762498..7b751877 100644
--- a/benchmark/set/string-long/insert.cpp
+++ b/benchmark/set/string-long/insert.cpp
@@ -8,4 +8,5 @@
#define DISABLE_GC_BENCHMARKS
#include "generator.ipp"
+
#include "../insert.ipp"
diff --git a/benchmark/set/string-long/iter.cpp b/benchmark/set/string-long/iter.cpp
index 83e57e78..48356c38 100644
--- a/benchmark/set/string-long/iter.cpp
+++ b/benchmark/set/string-long/iter.cpp
@@ -7,4 +7,5 @@
//
#include "generator.ipp"
+
#include "../iter.ipp"
diff --git a/benchmark/set/string-short/access.cpp b/benchmark/set/string-short/access.cpp
index c3deffbb..13f87d83 100644
--- a/benchmark/set/string-short/access.cpp
+++ b/benchmark/set/string-short/access.cpp
@@ -7,4 +7,5 @@
//
#include "generator.ipp"
+
#include "../access.ipp"
diff --git a/benchmark/set/string-short/insert.cpp b/benchmark/set/string-short/insert.cpp
index 26dfbce2..718aaad4 100644
--- a/benchmark/set/string-short/insert.cpp
+++ b/benchmark/set/string-short/insert.cpp
@@ -7,4 +7,5 @@
//
#include "generator.ipp"
+
#include "../insert.ipp"
diff --git a/benchmark/set/string-short/iter.cpp b/benchmark/set/string-short/iter.cpp
index 83e57e78..48356c38 100644
--- a/benchmark/set/string-short/iter.cpp
+++ b/benchmark/set/string-short/iter.cpp
@@ -7,4 +7,5 @@
//
#include "generator.ipp"
+
#include "../iter.ipp"
diff --git a/benchmark/set/unsigned/access.cpp b/benchmark/set/unsigned/access.cpp
index c3deffbb..13f87d83 100644
--- a/benchmark/set/unsigned/access.cpp
+++ b/benchmark/set/unsigned/access.cpp
@@ -7,4 +7,5 @@
//
#include "generator.ipp"
+
#include "../access.ipp"
diff --git a/benchmark/set/unsigned/insert.cpp b/benchmark/set/unsigned/insert.cpp
index 26dfbce2..718aaad4 100644
--- a/benchmark/set/unsigned/insert.cpp
+++ b/benchmark/set/unsigned/insert.cpp
@@ -7,4 +7,5 @@
//
#include "generator.ipp"
+
#include "../insert.ipp"
diff --git a/benchmark/set/unsigned/iter.cpp b/benchmark/set/unsigned/iter.cpp
index 83e57e78..48356c38 100644
--- a/benchmark/set/unsigned/iter.cpp
+++ b/benchmark/set/unsigned/iter.cpp
@@ -7,4 +7,5 @@
//
#include "generator.ipp"
+
#include "../iter.ipp"
diff --git a/benchmark/vector/access.hpp b/benchmark/vector/access.hpp
index 4dff7a66..7e23e543 100644
--- a/benchmark/vector/access.hpp
+++ b/benchmark/vector/access.hpp
@@ -21,15 +21,14 @@ namespace {
template
auto benchmark_access_reduce_chunkedseq()
{
- return [] (nonius::parameters params)
- {
+ return [](nonius::parameters params) {
auto n = params.get();
auto v = Vektor{};
for (auto i = 0u; i < n; ++i)
v.push_back(i);
return [=] {
auto init = 0u;
- v.for_each_segment([&] (auto first, auto last) {
+ v.for_each_segment([&](auto first, auto last) {
init = std::accumulate(first, last, init);
});
return init;
@@ -40,8 +39,7 @@ auto benchmark_access_reduce_chunkedseq()
template
auto benchmark_access_iter_std()
{
- return [] (nonius::parameters params)
- {
+ return [](nonius::parameters params) {
auto n = params.get();
auto v = Vektor{};
for (auto i = 0u; i < n; ++i)
@@ -56,8 +54,7 @@ auto benchmark_access_iter_std()
template
auto benchmark_access_idx_std()
{
- return [] (nonius::parameters params)
- {
+ return [](nonius::parameters params) {
auto n = params.get();
auto v = Vektor{};
for (auto i = 0u; i < n; ++i)
@@ -75,8 +72,7 @@ auto benchmark_access_idx_std()
template
auto benchmark_access_random_std()
{
- return [] (nonius::parameters params)
- {
+ return [](nonius::parameters params) {
auto n = params.get();
auto v = Vektor{};
auto g = make_generator(n);
@@ -92,11 +88,10 @@ auto benchmark_access_random_std()
};
}
-template
+template
auto benchmark_access_iter()
{
- return [] (nonius::parameters params)
- {
+ return [](nonius::parameters params) {
auto n = params.get();
auto v = Vektor{};
@@ -111,11 +106,10 @@ auto benchmark_access_iter()
}
#if IMMER_BENCHMARK_BOOST_COROUTINE
-template
+template
auto benchmark_access_coro()
{
- return [] (nonius::parameters params)
- {
+ return [](nonius::parameters params) {
using coro_t = typename boost::coroutines2::coroutine;
auto n = params.get();
@@ -125,7 +119,7 @@ auto benchmark_access_coro()
v = PushFn{}(std::move(v), i);
return [=] {
- auto c = coro_t::pull_type { [&](auto& sink) {
+ auto c = coro_t::pull_type{[&](auto& sink) {
v.for_each_chunk([&](auto f, auto l) {
for (; f != l; ++f)
sink(*f);
@@ -138,12 +132,10 @@ auto benchmark_access_coro()
}
#endif
-template
+template
auto benchmark_access_idx()
{
- return [] (nonius::parameters params)
- {
+ return [](nonius::parameters params) {
auto n = params.get();
auto v = Vektor{};
@@ -160,12 +152,10 @@ auto benchmark_access_idx()
};
}
-template
+template
auto benchmark_access_reduce()
{
- return [] (nonius::parameters params)
- {
+ return [](nonius::parameters params) {
auto n = params.get();
auto v = Vektor{};
@@ -179,12 +169,10 @@ auto benchmark_access_reduce()
};
}
-template
+template
auto benchmark_access_reduce_range()
{
- return [] (nonius::parameters params)
- {
+ return [](nonius::parameters params) {
auto n = params.get();
auto v = Vektor{};
@@ -198,12 +186,10 @@ auto benchmark_access_reduce_range()
};
}
-template
+template
auto benchmark_access_random()
{
- return [] (nonius::parameters params)
- {
+ return [](nonius::parameters params) {
auto n = params.get();
auto v = Vektor{};
@@ -224,38 +210,34 @@ auto benchmark_access_random()
template
auto benchmark_access_librrb(Fn maker)
{
- return
- [=] (nonius::parameters params) {
- auto n = params.get();
- auto v = maker(n);
- return
- [=] {
- auto r = 0u;
- for (auto i = 0u; i < n; ++i)
- r += reinterpret_cast(rrb_nth(v, i));
- volatile auto rr = r;
- return rr;
- };
+ return [=](nonius::parameters params) {
+ auto n = params.get();
+ auto v = maker(n);
+ return [=] {
+ auto r = 0u;
+ for (auto i = 0u; i < n; ++i)
+ r += reinterpret_cast(rrb_nth(v, i));
+ volatile auto rr = r;
+ return rr;
};
+ };
}
template
auto benchmark_access_random_librrb(Fn maker)
{
- return
- [=] (nonius::parameters params) {
- auto n = params.get();
- auto v = maker(n);
- auto g = make_generator(n);
- return
- [=] {
- auto r = 0u;
- for (auto i = 0u; i < n; ++i)
- r += reinterpret_cast(rrb_nth(v, g[i]));
- volatile auto rr = r;
- return rr;
- };
+ return [=](nonius::parameters params) {
+ auto n = params.get();
+ auto v = maker(n);
+ auto g = make_generator(n);
+ return [=] {
+ auto r = 0u;
+ for (auto i = 0u; i < n; ++i)
+ r += reinterpret_cast(rrb_nth(v, g[i]));
+ volatile auto rr = r;
+ return rr;
};
+ };
}
} // anonymous namespace
diff --git a/benchmark/vector/assoc.hpp b/benchmark/vector/assoc.hpp
index 5619d7ee..84f214d8 100644
--- a/benchmark/vector/assoc.hpp
+++ b/benchmark/vector/assoc.hpp
@@ -15,49 +15,44 @@ namespace {
template
auto benchmark_assoc_std()
{
- return
- [] (nonius::chronometer meter)
- {
- auto n = meter.param();
- auto v = Vektor(n, 0);
- std::iota(v.begin(), v.end(), 0u);
- auto all = std::vector(meter.runs(), v);
- meter.measure([&] (int iter) {
- auto& r = all[iter];
- for (auto i = 0u; i < n; ++i)
- r[i] = n - i;
- return r;
- });
- };
+ return [](nonius::chronometer meter) {
+ auto n = meter.param();
+ auto v = Vektor(n, 0);
+ std::iota(v.begin(), v.end(), 0u);
+ auto all = std::vector(meter.runs(), v);
+ meter.measure([&](int iter) {
+ auto& r = all[iter];
+ for (auto i = 0u; i < n; ++i)
+ r[i] = n - i;
+ return r;
+ });
+ };
}
template
auto benchmark_assoc_random_std()
{
- return
- [](nonius::chronometer meter)
- {
- auto n = meter.param();
- auto g = make_generator(n);
- auto v = Vektor(n, 0);
- std::iota(v.begin(), v.end(), 0u);
- auto all = std::vector(meter.runs(), v);
- meter.measure([&] (int iter) {
- auto& r = all[iter];
- for (auto i = 0u; i < n; ++i)
- r[g[i]] = n - i;
- return r;
- });
- };
+ return [](nonius::chronometer meter) {
+ auto n = meter.param();
+ auto g = make_generator(n);
+ auto v = Vektor(n, 0);
+ std::iota(v.begin(), v.end(), 0u);
+ auto all = std::vector(meter.runs(), v);
+ meter.measure([&](int iter) {
+ auto& r = all[iter];
+ for (auto i = 0u; i < n; ++i)
+ r[g[i]] = n - i;
+ return r;
+ });
+ };
}
template
+ typename PushFn = push_back_fn,
+ typename SetFn = set_fn>
auto benchmark_assoc()
{
- return [] (nonius::chronometer meter)
- {
+ return [](nonius::chronometer meter) {
auto n = meter.param();
if (n > get_limit{})
nonius::skip();
@@ -75,12 +70,10 @@ auto benchmark_assoc()
};
}
-template
+template
auto benchmark_assoc_move()
{
- return [] (nonius::chronometer meter)
- {
+ return [](nonius::chronometer meter) {
auto n = meter.param();
if (n > get_limit{})
nonius::skip();
@@ -99,12 +92,11 @@ auto benchmark_assoc_move()
}
template
+ typename PushFn = push_back_fn,
+ typename SetFn = set_fn>
auto benchmark_assoc_random()
{
- return [] (nonius::chronometer meter)
- {
+ return [](nonius::chronometer meter) {
auto n = meter.param();
if (n > get_limit{})
nonius::skip();
@@ -123,12 +115,10 @@ auto benchmark_assoc_random()
};
}
-template
+template
auto benchmark_assoc_mut()
{
- return [] (nonius::chronometer meter)
- {
+ return [](nonius::chronometer meter) {
auto n = meter.param();
if (n > get_limit{})
nonius::skip();
@@ -146,12 +136,10 @@ auto benchmark_assoc_mut()
};
}
-template
+template
auto benchmark_assoc_mut_random()
{
- return [] (nonius::chronometer meter)
- {
+ return [](nonius::chronometer meter) {
auto n = meter.param();
if (n > get_limit{})
nonius::skip();
@@ -173,73 +161,63 @@ auto benchmark_assoc_mut_random()
template
auto benchmark_assoc_librrb(Fn maker)
{
- return
- [=] (nonius::chronometer meter) {
- auto n = meter.param();
- auto v = maker(n);
- measure(
- meter, [&] {
- auto r = v;
- for (auto i = 0u; i < n; ++i)
- r = rrb_update(r, i, reinterpret_cast(n - i));
- return r;
- });
- };
+ return [=](nonius::chronometer meter) {
+ auto n = meter.param();
+ auto v = maker(n);
+ measure(meter, [&] {
+ auto r = v;
+ for (auto i = 0u; i < n; ++i)
+ r = rrb_update(r, i, reinterpret_cast(n - i));
+ return r;
+ });
+ };
}
template
auto benchmark_assoc_random_librrb(Fn maker)
{
- return
- [=] (nonius::chronometer meter) {
- auto n = meter.param();
- auto v = maker(n);
- auto g = make_generator(n);
- measure(
- meter, [&] {
- auto r = v;
- for (auto i = 0u; i < n; ++i)
- r = rrb_update(r, g[i], reinterpret_cast(i));
- return r;
- });
- };
+ return [=](nonius::chronometer meter) {
+ auto n = meter.param();
+ auto v = maker(n);
+ auto g = make_generator(n);
+ measure(meter, [&] {
+ auto r = v;
+ for (auto i = 0u; i < n; ++i)
+ r = rrb_update(r, g[i], reinterpret_cast(i));
+ return r;
+ });
+ };
}
template
auto benchmark_assoc_mut_librrb(Fn maker)
{
- return
- [=] (nonius::chronometer meter) {
- auto n = meter.param();
- auto v = maker(n);
- measure(
- meter, [&] {
- auto r = rrb_to_transient(v);
- for (auto i = 0u; i < n; ++i)
- r = transient_rrb_update(
- r, i, reinterpret_cast(i));
- return r;
- });
- };
+ return [=](nonius::chronometer meter) {
+ auto n = meter.param();
+ auto v = maker(n);
+ measure(meter, [&] {
+ auto r = rrb_to_transient(v);
+ for (auto i = 0u; i < n; ++i)
+ r = transient_rrb_update(r, i, reinterpret_cast(i));
+ return r;
+ });
+ };
}
template
auto benchmark_assoc_mut_random_librrb(Fn maker)
{
- return
- [=] (nonius::chronometer meter) {
- auto n = meter.param();
- auto v = maker(n);
- auto g = make_generator(n);
- measure(
- meter, [&] {
- auto r = rrb_to_transient(v);
- for (auto i = 0u; i < n; ++i)
- r = transient_rrb_update(
- r, g[i], reinterpret_cast(i));
- return r;
- });
- };
+ return [=](nonius::chronometer meter) {
+ auto n = meter.param();
+ auto v = maker(n);
+ auto g = make_generator(n);
+ measure(meter, [&] {
+ auto r = rrb_to_transient(v);
+ for (auto i = 0u; i < n; ++i)
+ r = transient_rrb_update(r, g[i], reinterpret_cast(i));
+ return r;
+ });
+ };
}
} // anonymous namespace
diff --git a/benchmark/vector/branching/access.ipp b/benchmark/vector/branching/access.ipp
index bd7f985d..323e6217 100644
--- a/benchmark/vector/branching/access.ipp
+++ b/benchmark/vector/branching/access.ipp
@@ -13,8 +13,12 @@
#error "define the MEMORY_T"
#endif
+// clang-format off
+
NONIUS_BENCHMARK("flex/3", benchmark_access_idx>())
NONIUS_BENCHMARK("flex/4", benchmark_access_idx>())
NONIUS_BENCHMARK("flex/5", benchmark_access_idx>())
NONIUS_BENCHMARK("flex/6", benchmark_access_idx>())
NONIUS_BENCHMARK("flex/7", benchmark_access_idx>())
+
+// clang-format on
diff --git a/benchmark/vector/branching/assoc.ipp b/benchmark/vector/branching/assoc.ipp
index 4aa9984f..f0289883 100644
--- a/benchmark/vector/branching/assoc.ipp
+++ b/benchmark/vector/branching/assoc.ipp
@@ -13,8 +13,12 @@
#error "define the MEMORY_T"
#endif
+// clang-format off
+
NONIUS_BENCHMARK("flex/3", benchmark_assoc>())
NONIUS_BENCHMARK("flex/4", benchmark_assoc>())
NONIUS_BENCHMARK("flex/5", benchmark_assoc>())
NONIUS_BENCHMARK("flex/6", benchmark_assoc>())
NONIUS_BENCHMARK("flex/7", benchmark_assoc>())
+
+// clang-format on
diff --git a/benchmark/vector/branching/concat.ipp b/benchmark/vector/branching/concat.ipp
index 0e21ca0b..1f5a7297 100644
--- a/benchmark/vector/branching/concat.ipp
+++ b/benchmark/vector/branching/concat.ipp
@@ -13,8 +13,12 @@
#error "define the MEMORY_T"
#endif
+// clang-format off
+
NONIUS_BENCHMARK("flex/3", benchmark_concat>())
NONIUS_BENCHMARK("flex/4", benchmark_concat>())
NONIUS_BENCHMARK("flex/5", benchmark_concat>())
NONIUS_BENCHMARK("flex/6", benchmark_concat>())
NONIUS_BENCHMARK("flex/7", benchmark_concat>())
+
+// clang-format on
diff --git a/benchmark/vector/branching/push.ipp b/benchmark/vector/branching/push.ipp
index 2f92d656..9a1389ab 100644
--- a/benchmark/vector/branching/push.ipp
+++ b/benchmark/vector/branching/push.ipp
@@ -13,8 +13,12 @@
#error "define the MEMORY_T"
#endif
+// clang-format off
+
NONIUS_BENCHMARK("flex/3", benchmark_push>())
NONIUS_BENCHMARK("flex/4", benchmark_push>())
NONIUS_BENCHMARK("flex/5", benchmark_push>())
NONIUS_BENCHMARK("flex/6", benchmark_push>())
NONIUS_BENCHMARK("flex/7", benchmark_push>())
+
+// clang-format on
diff --git a/benchmark/vector/common.hpp b/benchmark/vector/common.hpp
index c96d6d01..79b087d0 100644
--- a/benchmark/vector/common.hpp
+++ b/benchmark/vector/common.hpp
@@ -8,14 +8,15 @@
#pragma once
-#include
#include
#include
+#include
#include "benchmark/config.hpp"
#if IMMER_BENCHMARK_LIBRRB
-extern "C" {
+extern "C"
+{
#define restrict __restrict__
#include
#undef restrict
@@ -24,7 +25,8 @@ extern "C" {
#endif
namespace immer {
-template class array;
+template
+class array;
} // namespace immer
namespace {
@@ -33,8 +35,8 @@ auto make_generator(std::size_t runs)
{
assert(runs > 0);
auto engine = std::default_random_engine{42};
- auto dist = std::uniform_int_distribution{0, runs-1};
- auto r = std::vector(runs);
+ auto dist = std::uniform_int_distribution{0, runs - 1};
+ auto r = std::vector(runs);
std::generate_n(r.begin(), runs, std::bind(dist, engine));
return r;
}
@@ -42,38 +44,49 @@ auto make_generator(std::size_t runs)
struct push_back_fn
{
template
- auto operator() (T&& v, U&& x)
- { return std::forward(v).push_back(std::forward(x)); }
+ auto operator()(T&& v, U&& x)
+ {
+ return std::forward(v).push_back(std::forward(x));
+ }
};
struct push_front_fn
{
template
- auto operator() (T&& v, U&& x)
- { return std::forward(v).push_front(std::forward(x)); }
+ auto operator()(T&& v, U&& x)
+ {
+ return std::forward(v).push_front(std::forward(x));
+ }
};
struct set_fn
{
template
- decltype(auto) operator() (T&& v, I i, U&& x)
- { return std::forward(v).set(i, std::forward(x)); }
+ decltype(auto) operator()(T&& v, I i, U&& x)
+ {
+ return std::forward(v).set(i, std::forward(x));
+ }
};
struct store_fn
{
template
- decltype(auto) operator() (T&& v, I i, U&& x)
- { return std::forward(v).store(i, std::forward(x)); }
+ decltype(auto) operator()(T&& v, I i, U&& x)
+ {
+ return std::forward(v).store(i, std::forward(x));
+ }
};
template
-struct get_limit : std::integral_constant<
- std::size_t, std::numeric_limits::max()> {};
+struct get_limit
+ : std::integral_constant::max()>
+{};
template
-struct get_limit> : std::integral_constant<
- std::size_t, 10000> {};
+struct get_limit>
+ : std::integral_constant
+{};
auto make_librrb_vector(std::size_t n)
{
@@ -88,26 +101,26 @@ auto make_librrb_vector_f(std::size_t n)
{
auto v = rrb_create();
for (auto i = 0u; i < n; ++i) {
- auto f = rrb_push(rrb_create(),
- reinterpret_cast(i));
- v = rrb_concat(f, v);
+ auto f = rrb_push(rrb_create(), reinterpret_cast(i));
+ v = rrb_concat(f, v);
}
return v;
}
-
// copied from:
// https://github.com/ivmai/bdwgc/blob/master/include/gc_allocator.h
template
struct GC_type_traits
{
- std::false_type GC_is_ptr_free;
+ std::false_type GC_is_ptr_free;
};
-# define GC_DECLARE_PTRFREE(T) \
- template<> struct GC_type_traits { \
- std::true_type GC_is_ptr_free; \
+#define GC_DECLARE_PTRFREE(T) \
+ template <> \
+ struct GC_type_traits \
+ { \
+ std::true_type GC_is_ptr_free; \
}
GC_DECLARE_PTRFREE(char);
@@ -126,9 +139,7 @@ GC_DECLARE_PTRFREE(long double);
template
inline void* GC_selective_alloc(size_t n, IsPtrFree, bool ignore_off_page)
{
- return ignore_off_page
- ? GC_MALLOC_IGNORE_OFF_PAGE(n)
- : GC_MALLOC(n);
+ return ignore_off_page ? GC_MALLOC_IGNORE_OFF_PAGE(n) : GC_MALLOC(n);
}
template <>
@@ -136,31 +147,34 @@ inline void* GC_selective_alloc(size_t n,
std::true_type,
bool ignore_off_page)
{
- return ignore_off_page
- ? GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE(n)
- : GC_MALLOC_ATOMIC(n);
+ return ignore_off_page ? GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE(n)
+ : GC_MALLOC_ATOMIC(n);
}
template
class gc_allocator
{
public:
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef T* pointer;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef T* pointer;
typedef const T* const_pointer;
- typedef T& reference;
+ typedef T& reference;
typedef const T& const_reference;
- typedef T value_type;
+ typedef T value_type;
- template struct rebind {
+ template
+ struct rebind
+ {
typedef gc_allocator other;
};
- gc_allocator() {}
+ gc_allocator() {}
gc_allocator(const gc_allocator&) throw() {}
template
- explicit gc_allocator(const gc_allocator&) throw() {}
+ explicit gc_allocator(const gc_allocator&) throw()
+ {
+ }
~gc_allocator() throw() {}
pointer address(reference GC_x) const { return &GC_x; }
@@ -171,42 +185,45 @@ class gc_allocator
T* allocate(size_type GC_n, const void* = 0)
{
GC_type_traits traits;
- return static_cast
- (GC_selective_alloc(GC_n * sizeof(T),
- traits.GC_is_ptr_free, false));
+ return static_cast