From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/boost/libs/hana/benchmark/CMakeLists.txt | 91 ++++++++++++ src/boost/libs/hana/benchmark/chart.html | 40 +++++ .../libs/hana/benchmark/find_if/compile.erb.json | 53 +++++++ .../benchmark/find_if/compile.fusion.list.erb.cpp | 30 ++++ .../find_if/compile.fusion.vector.erb.cpp | 30 ++++ .../benchmark/find_if/compile.hana.map.erb.cpp | 29 ++++ .../benchmark/find_if/compile.hana.set.erb.cpp | 25 ++++ .../benchmark/find_if/compile.hana.tuple.erb.cpp | 24 +++ .../benchmark/find_if/compile.meta.list.erb.cpp | 21 +++ .../benchmark/find_if/compile.mpl.vector.erb.cpp | 27 ++++ .../find_if/compile.std.integer_sequence.erb.cpp | 27 ++++ .../libs/hana/benchmark/fold_left/bloat.erb.json | 38 +++++ .../fold_left/compile.cexpr.recursive.erb.cpp | 53 +++++++ .../fold_left/compile.cexpr.unrolled.erb.cpp | 43 ++++++ .../libs/hana/benchmark/fold_left/compile.erb.json | 61 ++++++++ .../fold_left/compile.fusion.list.erb.cpp | 31 ++++ .../fold_left/compile.fusion.vector.erb.cpp | 31 ++++ .../fold_left/compile.hana.basic_tuple.erb.cpp | 26 ++++ .../benchmark/fold_left/compile.hana.tuple.erb.cpp | 25 ++++ .../benchmark/fold_left/compile.meta.list.erb.cpp | 25 ++++ .../benchmark/fold_left/compile.mpl.vector.erb.cpp | 24 +++ .../benchmark/fold_left/compile.mpl11.list.erb.cpp | 26 ++++ .../libs/hana/benchmark/fold_left/execute.erb.json | 32 ++++ .../fold_left/execute.fusion.list.erb.cpp | 32 ++++ .../fold_left/execute.fusion.vector.erb.cpp | 32 ++++ .../benchmark/fold_left/execute.hana.tuple.erb.cpp | 26 ++++ .../benchmark/fold_left/execute.std.array.erb.cpp | 22 +++ .../benchmark/fold_left/execute.std.vector.erb.cpp | 22 +++ .../libs/hana/benchmark/including/baseline.erb.cpp | 6 + .../libs/hana/benchmark/including/compile.erb.json | 73 ++++++++++ .../libs/hana/benchmark/including/fusion.erb.cpp | 16 ++ .../libs/hana/benchmark/including/hana.erb.cpp | 8 + .../libs/hana/benchmark/including/meta.erb.cpp | 8 + .../libs/hana/benchmark/including/mpl.erb.cpp | 155 ++++++++++++++++++++ .../libs/hana/benchmark/including/mpl11.erb.cpp | 8 + .../libs/hana/benchmark/make/compile.erb.json | 58 ++++++++ .../benchmark/make/compile.fusion.list.erb.cpp | 15 ++ .../benchmark/make/compile.fusion.vector.erb.cpp | 15 ++ .../make/compile.hana.basic_tuple.erb.cpp | 16 ++ .../hana/benchmark/make/compile.hana.tuple.erb.cpp | 16 ++ .../hana/benchmark/make/compile.meta.list.erb.cpp | 17 +++ .../hana/benchmark/make/compile.mpl.vector.erb.cpp | 14 ++ .../hana/benchmark/make/compile.mpl11.list.erb.cpp | 17 +++ .../hana/benchmark/make/compile.std.array.erb.cpp | 16 ++ .../hana/benchmark/make/compile.std.tuple.erb.cpp | 16 ++ src/boost/libs/hana/benchmark/measure.hpp | 29 ++++ src/boost/libs/hana/benchmark/measure.in.rb | 161 +++++++++++++++++++++ .../libs/hana/benchmark/reverse/move.erb.json | 23 +++ .../benchmark/reverse/move.fusion.vector.erb.cpp | 33 +++++ .../hana/benchmark/reverse/move.hana.tuple.erb.cpp | 27 ++++ .../libs/hana/benchmark/reverse/nomove.erb.json | 23 +++ .../benchmark/reverse/nomove.fusion.vector.erb.cpp | 33 +++++ .../benchmark/reverse/nomove.hana.tuple.erb.cpp | 27 ++++ .../libs/hana/benchmark/sort/compile.erb.json | 31 ++++ .../benchmark/sort/compile.hana.tuple.rand.erb.cpp | 14 ++ .../sort/compile.hana.tuple.reversed.erb.cpp | 14 ++ .../sort/compile.hana.tuple.sorted.erb.cpp | 14 ++ .../compile.hana.tuple.sorted_but_first.erb.cpp | 14 ++ .../compile.hana.tuple.sorted_but_last.erb.cpp | 14 ++ .../libs/hana/benchmark/transform/bloat.erb.json | 42 ++++++ .../libs/hana/benchmark/transform/compile.erb.json | 49 +++++++ .../transform/compile.fusion.list.erb.cpp | 30 ++++ .../transform/compile.fusion.vector.erb.cpp | 30 ++++ .../benchmark/transform/compile.hana.tuple.erb.cpp | 23 +++ .../benchmark/transform/compile.hana.types.erb.cpp | 26 ++++ .../benchmark/transform/compile.meta.list.erb.cpp | 23 +++ .../benchmark/transform/compile.mpl.vector.erb.cpp | 22 +++ .../benchmark/transform/compile.mpl11.list.erb.cpp | 24 +++ .../libs/hana/benchmark/transform/execute.erb.json | 36 +++++ .../transform/execute.fusion.list.erb.cpp | 33 +++++ .../transform/execute.fusion.vector.erb.cpp | 33 +++++ .../benchmark/transform/execute.hana.tuple.erb.cpp | 26 ++++ .../benchmark/transform/execute.std.array.erb.cpp | 26 ++++ .../benchmark/transform/execute.std.vector.erb.cpp | 27 ++++ 74 files changed, 2327 insertions(+) create mode 100644 src/boost/libs/hana/benchmark/CMakeLists.txt create mode 100644 src/boost/libs/hana/benchmark/chart.html create mode 100644 src/boost/libs/hana/benchmark/find_if/compile.erb.json create mode 100644 src/boost/libs/hana/benchmark/find_if/compile.fusion.list.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/find_if/compile.fusion.vector.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/find_if/compile.hana.map.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/find_if/compile.hana.set.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/find_if/compile.hana.tuple.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/find_if/compile.meta.list.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/find_if/compile.mpl.vector.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/find_if/compile.std.integer_sequence.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/bloat.erb.json create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.cexpr.recursive.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.cexpr.unrolled.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.erb.json create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.fusion.list.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.fusion.vector.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.hana.basic_tuple.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.hana.tuple.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.meta.list.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.mpl.vector.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/compile.mpl11.list.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/execute.erb.json create mode 100644 src/boost/libs/hana/benchmark/fold_left/execute.fusion.list.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/execute.fusion.vector.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/execute.hana.tuple.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/execute.std.array.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/fold_left/execute.std.vector.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/including/baseline.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/including/compile.erb.json create mode 100644 src/boost/libs/hana/benchmark/including/fusion.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/including/hana.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/including/meta.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/including/mpl.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/including/mpl11.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/make/compile.erb.json create mode 100644 src/boost/libs/hana/benchmark/make/compile.fusion.list.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/make/compile.fusion.vector.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/make/compile.hana.basic_tuple.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/make/compile.hana.tuple.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/make/compile.meta.list.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/make/compile.mpl.vector.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/make/compile.mpl11.list.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/make/compile.std.array.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/make/compile.std.tuple.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/measure.hpp create mode 100755 src/boost/libs/hana/benchmark/measure.in.rb create mode 100644 src/boost/libs/hana/benchmark/reverse/move.erb.json create mode 100644 src/boost/libs/hana/benchmark/reverse/move.fusion.vector.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/reverse/move.hana.tuple.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/reverse/nomove.erb.json create mode 100644 src/boost/libs/hana/benchmark/reverse/nomove.fusion.vector.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/reverse/nomove.hana.tuple.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/sort/compile.erb.json create mode 100644 src/boost/libs/hana/benchmark/sort/compile.hana.tuple.rand.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/sort/compile.hana.tuple.reversed.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/sort/compile.hana.tuple.sorted.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/sort/compile.hana.tuple.sorted_but_first.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/sort/compile.hana.tuple.sorted_but_last.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/transform/bloat.erb.json create mode 100644 src/boost/libs/hana/benchmark/transform/compile.erb.json create mode 100644 src/boost/libs/hana/benchmark/transform/compile.fusion.list.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/transform/compile.fusion.vector.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/transform/compile.hana.tuple.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/transform/compile.hana.types.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/transform/compile.meta.list.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/transform/compile.mpl.vector.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/transform/compile.mpl11.list.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/transform/execute.erb.json create mode 100644 src/boost/libs/hana/benchmark/transform/execute.fusion.list.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/transform/execute.fusion.vector.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/transform/execute.hana.tuple.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/transform/execute.std.array.erb.cpp create mode 100644 src/boost/libs/hana/benchmark/transform/execute.std.vector.erb.cpp (limited to 'src/boost/libs/hana/benchmark') diff --git a/src/boost/libs/hana/benchmark/CMakeLists.txt b/src/boost/libs/hana/benchmark/CMakeLists.txt new file mode 100644 index 000000000..212454563 --- /dev/null +++ b/src/boost/libs/hana/benchmark/CMakeLists.txt @@ -0,0 +1,91 @@ +# Copyright Louis Dionne 2013-2017 +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +############################################################################## +# Required packages, gems and caveats +############################################################################## +find_package(Ruby 2.1) +if(NOT ${RUBY_FOUND}) + message(WARNING "Ruby >= 2.1 was not found; the benchmarks will be unavailable.") + return() +endif() + +# Check for the 'ruby-progressbar' and 'tilt' gems +execute_process(COMMAND ${RUBY_EXECUTABLE} -r ruby-progressbar -r tilt -e "" + RESULT_VARIABLE __BOOST_HANA_MISSING_GEMS + OUTPUT_QUIET ERROR_QUIET) +if(${__BOOST_HANA_MISSING_GEMS}) + message(WARNING + "The 'ruby-progressbar' and/or 'tilt' gems were not found; " + "the benchmarks will be unavailable." + "Use `gem install ruby-progressbar tilt` to install the missing gems.") + return() +endif() + +# Some benchmarks depend on those libraries +find_package(MPL11) +find_package(Meta) + +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag(-ftemplate-depth=-1 BOOST_HANA_HAS_FTEMPLATE_DEPTH) + +############################################################################## +# Configure the measure.rb script +############################################################################## +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/measure.in.rb #input + ${CMAKE_CURRENT_BINARY_DIR}/measure.rb #output + @ONLY) + +############################################################################## +# Add the benchmarks +############################################################################## +add_custom_target(benchmarks COMMENT "Generate all the benchmarks.") + +add_custom_target(travis_compiler_slug USES_TERMINAL + COMMAND ${CMAKE_COMMAND} -E echo "travis_compiler_slug: $") +add_custom_target(travis_config_slug USES_TERMINAL + COMMAND ${CMAKE_COMMAND} -E echo "travis_config_slug: $>") + +file(GLOB_RECURSE BOOST_HANA_BENCHMARKS *.erb.json) +foreach(benchmark IN LISTS BOOST_HANA_BENCHMARKS) + boost_hana_target_name_for(target ${benchmark} ".erb.json") + get_filename_component(directory "${benchmark}" DIRECTORY) + file(GLOB cpp_files "${directory}/*.erb.cpp") + configure_file("${benchmark}" "${CMAKE_CURRENT_BINARY_DIR}/${target}.erb.json" @ONLY) + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${target}.measure.cpp" "") + add_executable(${target}.measure EXCLUDE_FROM_ALL "${CMAKE_CURRENT_BINARY_DIR}/${target}.measure.cpp") + target_include_directories(${target}.measure PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") + if (MPL11_FOUND) + target_include_directories(${target}.measure PRIVATE "${MPL11_INCLUDE_DIR}") + endif() + if (Meta_FOUND) + target_include_directories(${target}.measure PRIVATE "${Meta_INCLUDE_DIR}") + endif() + if (Boost_FOUND) + target_link_libraries(${target}.measure PRIVATE Boost::boost) + endif() + boost_hana_set_test_properties(${target}.measure) + if (BOOST_HANA_HAS_FTEMPLATE_DEPTH) + target_compile_options(${target}.measure PRIVATE -ftemplate-depth=-1) + endif() + set_target_properties(${target}.measure PROPERTIES RULE_LAUNCH_COMPILE "${CMAKE_CURRENT_BINARY_DIR}/measure.rb") + set_property(TARGET ${target}.measure APPEND PROPERTY INCLUDE_DIRECTORIES "${directory}") + add_custom_target(${target}.measure.run COMMAND ${target}.measure) + + add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${target}.json" + COMMAND ${RUBY_EXECUTABLE} -r tilt -r "${CMAKE_CURRENT_BINARY_DIR}/measure.rb" + -e "MEASURE_FILE = '${CMAKE_CURRENT_BINARY_DIR}/${target}.measure.cpp'" + -e "MEASURE_TARGET = '${target}.measure'" + -e "json = Tilt::ERBTemplate.new('${CMAKE_CURRENT_BINARY_DIR}/${target}.erb.json').render" + -e "File.open('${CMAKE_CURRENT_BINARY_DIR}/${target}.json', 'w') { |f| f.write(json) } " + WORKING_DIRECTORY ${directory} + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${target}.erb.json" ${cpp_files} + VERBATIM USES_TERMINAL + COMMENT "Generating dataset for ${target}" + ) + + add_custom_target(${target} DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${target}.json") + add_dependencies(benchmarks ${target}) +endforeach() diff --git a/src/boost/libs/hana/benchmark/chart.html b/src/boost/libs/hana/benchmark/chart.html new file mode 100644 index 000000000..55718cefa --- /dev/null +++ b/src/boost/libs/hana/benchmark/chart.html @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + +
+ + + + + diff --git a/src/boost/libs/hana/benchmark/find_if/compile.erb.json b/src/boost/libs/hana/benchmark/find_if/compile.erb.json new file mode 100644 index 000000000..da6542b55 --- /dev/null +++ b/src/boost/libs/hana/benchmark/find_if/compile.erb.json @@ -0,0 +1,53 @@ +<% + hana = (0...50).step(5).to_a + (50..200).step(25).to_a + fusion = (0...50).step(5).to_a + mpl = hana + meta = hana +%> + +{ + "title": { + "text": "Compile-time behavior of find_if" + }, + "series": [ + { + "name": "hana::tuple", + "data": <%= time_compilation('compile.hana.tuple.erb.cpp', hana) %> + } + + <% if false %> + , { + "name": "hana::set", + "data": <%= time_compilation('compile.hana.set.erb.cpp', hana) %> + }, { + "name": "hana::map", + "data": <%= time_compilation('compile.hana.map.erb.cpp', hana) %> + } + <% end %> + + , { + "name": "std::integer_sequence", + "data": <%= time_compilation('compile.std.integer_sequence.erb.cpp', hana) %> + } + + <% if cmake_bool("@Boost_FOUND@") %> + , { + "name": "fusion::vector", + "data": <%= time_compilation('compile.fusion.vector.erb.cpp', fusion) %> + }, { + "name": "fusion::list", + "data": <%= time_compilation('compile.fusion.list.erb.cpp', fusion) %> + }, { + "name": "mpl::vector", + "data": <%= time_compilation('compile.mpl.vector.erb.cpp', mpl) %> + } + <% end %> + + <% if cmake_bool("@Meta_FOUND@") %> + , { + "name": "meta::list", + "data": <%= time_compilation('compile.meta.list.erb.cpp', meta) %> + } + <% end %> + ] +} diff --git a/src/boost/libs/hana/benchmark/find_if/compile.fusion.list.erb.cpp b/src/boost/libs/hana/benchmark/find_if/compile.fusion.list.erb.cpp new file mode 100644 index 000000000..a7c0ca90e --- /dev/null +++ b/src/boost/libs/hana/benchmark/find_if/compile.fusion.list.erb.cpp @@ -0,0 +1,30 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +<% if input_size > 10 %> + #define FUSION_MAX_LIST_SIZE <%= ((input_size + 9) / 10) * 10 %> +<% end %> + +#include +#include +#include +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + + +struct is_last { + template + struct apply + : mpl::integral_c> + { }; +}; + +int main() { + auto ints = fusion::make_list( + <%= (1..input_size).map { |n| "mpl::integral_c{}" }.join(', ') %> + ); + + auto result = fusion::find_if(ints); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/find_if/compile.fusion.vector.erb.cpp b/src/boost/libs/hana/benchmark/find_if/compile.fusion.vector.erb.cpp new file mode 100644 index 000000000..067cbaae5 --- /dev/null +++ b/src/boost/libs/hana/benchmark/find_if/compile.fusion.vector.erb.cpp @@ -0,0 +1,30 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +<% if input_size > 10 %> + #define FUSION_MAX_VECTOR_SIZE <%= ((input_size + 9) / 10) * 10 %> +<% end %> + +#include +#include +#include +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + + +struct is_last { + template + struct apply + : mpl::integral_c> + { }; +}; + +int main() { + auto ints = fusion::make_vector( + <%= (1..input_size).map { |n| "mpl::integral_c{}" }.join(', ') %> + ); + + auto result = fusion::find_if(ints); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/find_if/compile.hana.map.erb.cpp b/src/boost/libs/hana/benchmark/find_if/compile.hana.map.erb.cpp new file mode 100644 index 000000000..8b600973f --- /dev/null +++ b/src/boost/libs/hana/benchmark/find_if/compile.hana.map.erb.cpp @@ -0,0 +1,29 @@ +// Copyright Jason Rice 2015 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +namespace hana = boost::hana; + + +struct is_last { + template + constexpr auto operator()(N) const { + return hana::bool_c>; + } +}; + +struct undefined {}; + +int main() { + constexpr auto map = hana::make_map( + <%= (1..input_size).map { |n| + "hana::make_pair(hana::int_c<#{n}>, undefined{})" + }.join(', ') %> + ); + constexpr auto result = hana::find_if(map, is_last{}); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/find_if/compile.hana.set.erb.cpp b/src/boost/libs/hana/benchmark/find_if/compile.hana.set.erb.cpp new file mode 100644 index 000000000..6ce318786 --- /dev/null +++ b/src/boost/libs/hana/benchmark/find_if/compile.hana.set.erb.cpp @@ -0,0 +1,25 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +namespace hana = boost::hana; + + +struct is_last { + template + constexpr auto operator()(N) const { + return hana::bool_c>; + } +}; + +int main() { + constexpr auto set = hana::make_set( + <%= (1..input_size).map { |n| "hana::int_c<#{n}>" }.join(', ') %> + ); + constexpr auto result = hana::find_if(set, is_last{}); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/find_if/compile.hana.tuple.erb.cpp b/src/boost/libs/hana/benchmark/find_if/compile.hana.tuple.erb.cpp new file mode 100644 index 000000000..7e4684b65 --- /dev/null +++ b/src/boost/libs/hana/benchmark/find_if/compile.hana.tuple.erb.cpp @@ -0,0 +1,24 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + + +struct is_last { + template + constexpr auto operator()(N) const { + return boost::hana::bool_c>; + } +}; + +int main() { + constexpr auto tuple = boost::hana::make_tuple( + <%= (1..input_size).map { |n| "boost::hana::int_c<#{n}>" }.join(', ') %> + ); + constexpr auto result = boost::hana::find_if(tuple, is_last{}); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/find_if/compile.meta.list.erb.cpp b/src/boost/libs/hana/benchmark/find_if/compile.meta.list.erb.cpp new file mode 100644 index 000000000..4c2e61aa7 --- /dev/null +++ b/src/boost/libs/hana/benchmark/find_if/compile.meta.list.erb.cpp @@ -0,0 +1,21 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + + +struct is_last { + template + using apply = meta::bool_>; +}; + +using list = meta::list< + <%= (1..input_size).map { |i| "meta::int_<#{i}>" }.join(', ') %> +>; + +using result = meta::find_if; + +int main() { + +} diff --git a/src/boost/libs/hana/benchmark/find_if/compile.mpl.vector.erb.cpp b/src/boost/libs/hana/benchmark/find_if/compile.mpl.vector.erb.cpp new file mode 100644 index 000000000..b6b42a702 --- /dev/null +++ b/src/boost/libs/hana/benchmark/find_if/compile.mpl.vector.erb.cpp @@ -0,0 +1,27 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +namespace mpl = boost::mpl; + + +struct is_last { + template + struct apply + : mpl::integral_c> + { }; +}; + +using vector = <%= mpl_vector((1..input_size).to_a.map { |n| + "mpl::integral_c" +}) %>; + +using result = mpl::find_if::type; + + +int main() { } diff --git a/src/boost/libs/hana/benchmark/find_if/compile.std.integer_sequence.erb.cpp b/src/boost/libs/hana/benchmark/find_if/compile.std.integer_sequence.erb.cpp new file mode 100644 index 000000000..1e5194599 --- /dev/null +++ b/src/boost/libs/hana/benchmark/find_if/compile.std.integer_sequence.erb.cpp @@ -0,0 +1,27 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +struct is_last { + template + constexpr auto operator()(N) const { + return hana::bool_c>; + } +}; + +int main() { + auto sequence = std::integer_sequence< + <%= (["int"] + (1..input_size).to_a).join(', ') %> + >{}; + auto result = hana::find_if(sequence, is_last{}); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/fold_left/bloat.erb.json b/src/boost/libs/hana/benchmark/fold_left/bloat.erb.json new file mode 100644 index 000000000..b3bd9892e --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/bloat.erb.json @@ -0,0 +1,38 @@ +<% + exec = (0..100).step(10).to_a + fusion = (0..50).step(10).to_a +%> + +{ + "title": { + "text": "Executable size for fold_left" + }, + "yAxis": { + "title": { + "text": "Executable size (kb)" + }, + "floor": 0 + }, + "tooltip": { + "valueSuffix": "kb" + }, + "series": [ + { + "name": "hana::tuple", + "data": <%= measure(:bloat, 'execute.hana.tuple.erb.cpp', exec) %> + }, { + "name": "std::vector", + "data": <%= measure(:bloat, 'execute.std.vector.erb.cpp', exec) %> + }, { + "name": "std::array", + "data": <%= measure(:bloat, 'execute.std.array.erb.cpp', exec) %> + } + + <% if cmake_bool("@Boost_FOUND@") %> + , { + "name": "fusion::vector", + "data": <%= measure(:bloat, 'execute.fusion.vector.erb.cpp', fusion) %> + } + <% end %> + ] +} \ No newline at end of file diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.cexpr.recursive.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/compile.cexpr.recursive.erb.cpp new file mode 100644 index 000000000..30beb1698 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.cexpr.recursive.erb.cpp @@ -0,0 +1,53 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +template +struct list { }; + +template +struct basic_type { using type = T; }; + +template +constexpr basic_type type{}; + + +template +constexpr auto head(list) +{ return type; } + +template +constexpr auto tail(list) +{ return list{}; } + +template +constexpr auto foldl(F f, State s, list xs) +{ return foldl(f, f(s, head(xs)), tail(xs)); } + +template +constexpr auto foldl(F, State s, list<>) +{ return s; } + +////////////////////////////////////////////////////////////////////////////// + + +struct f { + template + struct result { }; + + template + constexpr auto operator()(X, Y) const + { return result{}; } +}; + +template struct x { }; +struct state { }; + +int main() { + constexpr auto xs = list< + <%= (1..input_size).map { |i| "x<#{i}>" }.join(', ') %> + >{}; + + constexpr auto result = foldl(f{}, state{}, xs); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.cexpr.unrolled.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/compile.cexpr.unrolled.erb.cpp new file mode 100644 index 000000000..80fb46f05 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.cexpr.unrolled.erb.cpp @@ -0,0 +1,43 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + + +template +struct list { }; + +template +struct basic_type { using type = T; }; + +template +constexpr basic_type type{}; + + +template +constexpr auto foldl(F f, State s, list xs) +{ return boost::hana::detail::variadic::foldl(f, s, type...); } + +////////////////////////////////////////////////////////////////////////////// + +struct f { + template + struct result { }; + + template + constexpr auto operator()(X, Y) const + { return result{}; } +}; + +template struct x { }; +struct state { }; + +int main() { + constexpr auto xs = list< + <%= (1..input_size).map { |i| "x<#{i}>" }.join(', ') %> + >{}; + + constexpr auto result = foldl(f{}, state{}, xs); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.erb.json b/src/boost/libs/hana/benchmark/fold_left/compile.erb.json new file mode 100644 index 000000000..7240907a9 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.erb.json @@ -0,0 +1,61 @@ +<% + hana = (0...50).step(5).to_a + (50..400).step(25).to_a + fusion = (0..50).step(5) + mpl = hana + mpl11 = (0...50).step(5).to_a + (50..500).step(25).to_a + meta = (0...50).step(5).to_a + (50..200).step(25).to_a + cexpr = (0...50).step(5).to_a + (50..200).step(25).to_a +%> + + +{ + "title": { + "text": "Compile-time behavior of fold_left" + }, + "series": [ + { + "name": "hana::tuple", + "data": <%= time_compilation('compile.hana.tuple.erb.cpp', hana) %> + }, { + "name": "hana::basic_tuple", + "data": <%= time_compilation('compile.hana.basic_tuple.erb.cpp', hana) %> + } + + <% if cmake_bool("@Boost_FOUND@") %> + , { + "name": "fusion::vector", + "data": <%= time_compilation('compile.fusion.vector.erb.cpp', fusion) %> + },{ + "name": "fusion::list", + "data": <%= time_compilation('compile.fusion.list.erb.cpp', fusion) %> + }, { + "name": "mpl::vector", + "data": <%= time_compilation('compile.mpl.vector.erb.cpp', mpl) %> + } + <% end %> + + <% if cmake_bool("@MPL11_FOUND@") %> + , { + "name": "mpl11::list", + "data": <%= time_compilation('compile.mpl11.list.erb.cpp', mpl11) %> + } + <% end %> + + <% if cmake_bool("@Meta_FOUND@") %> + , { + "name": "meta::list", + "data": <%= time_compilation('compile.meta.list.erb.cpp', meta) %> + } + <% end %> + + <% if false %> + , { + "name": "cexpr::list (recursive)", + "data": <%= time_compilation('compile.cexpr.recursive.erb.cpp', cexpr) %> + }, { + "name": "cexpr::list (unrolled)", + "data": <%= time_compilation('compile.cexpr.unrolled.erb.cpp', cexpr) %> + } + <% end %> + ] +} diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.fusion.list.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/compile.fusion.list.erb.cpp new file mode 100644 index 000000000..144744a23 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.fusion.list.erb.cpp @@ -0,0 +1,31 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +<% if input_size > 10 %> + #define FUSION_MAX_LIST_SIZE <%= ((input_size + 9) / 10) * 10 %> +<% end %> + +#include +#include +namespace fusion = boost::fusion; + + +struct f { + template + constexpr X operator()(State, X x) const { return x; } +}; + +struct state { }; + +template +struct x { }; + +int main() { + auto xs = fusion::make_list( + <%= (1..input_size).map { |n| "x<#{n}>{}" }.join(', ') %> + ); + + auto result = fusion::fold(xs, state{}, f{}); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.fusion.vector.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/compile.fusion.vector.erb.cpp new file mode 100644 index 000000000..3a319b351 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.fusion.vector.erb.cpp @@ -0,0 +1,31 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +<% if input_size > 10 %> + #define FUSION_MAX_VECTOR_SIZE <%= ((input_size + 9) / 10) * 10 %> +<% end %> + +#include +#include +namespace fusion = boost::fusion; + + +struct f { + template + constexpr X operator()(State, X x) const { return x; } +}; + +struct state { }; + +template +struct x { }; + +int main() { + auto xs = fusion::make_vector( + <%= (1..input_size).map { |n| "x<#{n}>{}" }.join(', ') %> + ); + + auto result = fusion::fold(xs, state{}, f{}); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.hana.basic_tuple.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/compile.hana.basic_tuple.erb.cpp new file mode 100644 index 000000000..c076f3fc9 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.hana.basic_tuple.erb.cpp @@ -0,0 +1,26 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +namespace hana = boost::hana; + + +struct f { + template + constexpr X operator()(State, X x) const { return x; } +}; + +struct state { }; + +template +struct x { }; + +int main() { + constexpr auto tuple = hana::make_basic_tuple( + <%= (1..input_size).map { |n| "x<#{n}>{}" }.join(', ') %> + ); + constexpr auto result = hana::fold_left(tuple, state{}, f{}); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.hana.tuple.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/compile.hana.tuple.erb.cpp new file mode 100644 index 000000000..a245e30c9 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.hana.tuple.erb.cpp @@ -0,0 +1,25 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + + +struct f { + template + constexpr X operator()(State, X x) const { return x; } +}; + +struct state { }; + +template +struct x { }; + +int main() { + constexpr auto tuple = boost::hana::make_tuple( + <%= (1..input_size).map { |n| "x<#{n}>{}" }.join(', ') %> + ); + constexpr auto result = boost::hana::fold_left(tuple, state{}, f{}); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.meta.list.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/compile.meta.list.erb.cpp new file mode 100644 index 000000000..cd2ec0f8a --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.meta.list.erb.cpp @@ -0,0 +1,25 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + + +struct f { + template + struct apply; +}; + +template struct x; + +struct state; + +using list = meta::list< + <%= (1..input_size).map { |i| "x<#{i}>" }.join(', ') %> +>; + +using result = meta::fold; + +int main() { + +} diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.mpl.vector.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/compile.mpl.vector.erb.cpp new file mode 100644 index 000000000..4d5b5b4b6 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.mpl.vector.erb.cpp @@ -0,0 +1,24 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + + +template +struct f { using type = X; }; + +struct state { }; + +template +struct t { }; + +using vector = <%= mpl_vector((1..input_size).to_a.map { |n| "t<#{n}>" }) %>; + +using result = boost::mpl::fold>::type; + + +int main() { } diff --git a/src/boost/libs/hana/benchmark/fold_left/compile.mpl11.list.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/compile.mpl11.list.erb.cpp new file mode 100644 index 000000000..cf383ef00 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/compile.mpl11.list.erb.cpp @@ -0,0 +1,26 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + + +struct f { + using type = f; + template + struct apply { struct type; }; +}; + +template struct x { struct type; }; + +struct state { struct type; }; + +using list = boost::mpl11::list< + <%= (1..input_size).map { |i| "x<#{i}>" }.join(', ') %> +>; + +using result = boost::mpl11::foldl::type; + +int main() { + +} diff --git a/src/boost/libs/hana/benchmark/fold_left/execute.erb.json b/src/boost/libs/hana/benchmark/fold_left/execute.erb.json new file mode 100644 index 000000000..2f7d94559 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/execute.erb.json @@ -0,0 +1,32 @@ +<% + exec = (0..100).step(10).to_a + fusion = (0..50).step(10).to_a +%> + +{ + "title": { + "text": "Runtime behavior of fold_left" + }, + "series": [ + { + "name": "hana::tuple", + "data": <%= time_execution('execute.hana.tuple.erb.cpp', exec) %> + }, { + "name": "std::vector", + "data": <%= time_execution('execute.std.vector.erb.cpp', exec) %> + }, { + "name": "std::array", + "data": <%= time_execution('execute.std.array.erb.cpp', exec) %> + } + + <% if cmake_bool("@Boost_FOUND@") %> + , { + "name": "fusion::vector", + "data": <%= time_execution('execute.fusion.vector.erb.cpp', fusion) %> + }, { + "name": "fusion::list", + "data": <%= time_execution('execute.fusion.list.erb.cpp', fusion) %> + } + <% end %> + ] +} \ No newline at end of file diff --git a/src/boost/libs/hana/benchmark/fold_left/execute.fusion.list.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/execute.fusion.list.erb.cpp new file mode 100644 index 000000000..b71938980 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/execute.fusion.list.erb.cpp @@ -0,0 +1,32 @@ +// Copyright Louis Dionne 2013-2017 +// Copyright Zach Laine 2014 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +<% if input_size > 10 %> + #define FUSION_MAX_LIST_SIZE <%= ((input_size + 9) / 10) * 10 %> +<% end %> + +#include +#include + +#include "measure.hpp" +#include +namespace fusion = boost::fusion; +namespace hana = boost::hana; + + +int main () { + hana::benchmark::measure([] { + long double result = 0; + for (int iteration = 0; iteration < 1 << 10; ++iteration) { + auto values = fusion::make_list( + <%= input_size.times.map { 'std::rand()' }.join(', ') %> + ); + + result += fusion::fold(values, 0, [](auto state, auto t) { + return state + t; + }); + } + }); +} diff --git a/src/boost/libs/hana/benchmark/fold_left/execute.fusion.vector.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/execute.fusion.vector.erb.cpp new file mode 100644 index 000000000..c733a3be0 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/execute.fusion.vector.erb.cpp @@ -0,0 +1,32 @@ +// Copyright Louis Dionne 2013-2017 +// Copyright Zach Laine 2014 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +<% if input_size > 10 %> + #define FUSION_MAX_VECTOR_SIZE <%= ((input_size + 9) / 10) * 10 %> +<% end %> + +#include +#include + +#include "measure.hpp" +#include +namespace fusion = boost::fusion; +namespace hana = boost::hana; + + +int main () { + hana::benchmark::measure([] { + long double result = 0; + for (int iteration = 0; iteration < 1 << 10; ++iteration) { + auto values = fusion::make_vector( + <%= input_size.times.map { 'std::rand()' }.join(', ') %> + ); + + result += fusion::fold(values, 0, [](auto state, auto t) { + return state + t; + }); + } + }); +} diff --git a/src/boost/libs/hana/benchmark/fold_left/execute.hana.tuple.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/execute.hana.tuple.erb.cpp new file mode 100644 index 000000000..622d74f88 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/execute.hana.tuple.erb.cpp @@ -0,0 +1,26 @@ +// Copyright Louis Dionne 2013-2017 +// Copyright Zach Laine 2014 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include "measure.hpp" +#include + + +int main () { + boost::hana::benchmark::measure([] { + long double result = 0; + for (int iteration = 0; iteration < 1 << 10; ++iteration) { + auto values = boost::hana::make_tuple( + <%= input_size.times.map { 'std::rand()' }.join(', ') %> + ); + + result += boost::hana::fold_left(values, 0, [](auto state, auto t) { + return state + t; + }); + } + }); +} diff --git a/src/boost/libs/hana/benchmark/fold_left/execute.std.array.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/execute.std.array.erb.cpp new file mode 100644 index 000000000..3961151b6 --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/execute.std.array.erb.cpp @@ -0,0 +1,22 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "measure.hpp" +#include +#include +#include + + +int main () { + boost::hana::benchmark::measure([] { + long long result = 0; + for (int iteration = 0; iteration < 1 << 10; ++iteration) { + std::array> values = {{ + <%= input_size.times.map { 'std::rand()' }.join(', ') %> + }}; + + result += std::accumulate(values.begin(), values.end(), 0); + } + }); +} diff --git a/src/boost/libs/hana/benchmark/fold_left/execute.std.vector.erb.cpp b/src/boost/libs/hana/benchmark/fold_left/execute.std.vector.erb.cpp new file mode 100644 index 000000000..703b6fbcc --- /dev/null +++ b/src/boost/libs/hana/benchmark/fold_left/execute.std.vector.erb.cpp @@ -0,0 +1,22 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "measure.hpp" +#include +#include +#include + + +int main () { + boost::hana::benchmark::measure([] { + long long result = 0; + for (int iteration = 0; iteration < 1 << 10; ++iteration) { + std::vector values = { + <%= input_size.times.map { 'std::rand()' }.join(', ') %> + }; + + result += std::accumulate(values.begin(), values.end(), 0); + } + }); +} diff --git a/src/boost/libs/hana/benchmark/including/baseline.erb.cpp b/src/boost/libs/hana/benchmark/including/baseline.erb.cpp new file mode 100644 index 000000000..932facb47 --- /dev/null +++ b/src/boost/libs/hana/benchmark/including/baseline.erb.cpp @@ -0,0 +1,6 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + + +int main() { } diff --git a/src/boost/libs/hana/benchmark/including/compile.erb.json b/src/boost/libs/hana/benchmark/including/compile.erb.json new file mode 100644 index 000000000..2441a4ee1 --- /dev/null +++ b/src/boost/libs/hana/benchmark/including/compile.erb.json @@ -0,0 +1,73 @@ +<% + def self.avg(xs) + xs.inject(0, :+) / xs.length + end + + def self.amortize(file) + # We remove the first one to mitigate cache effects + times = time_compilation(file, 6.times) + times.shift + avg(times.map { |_, t| t }) + end +%> + +{ + "chart": { + "type": "column" + }, + "legend": { + "enabled": false + }, + "xAxis": { + "type": "category" + }, + "title": { + "text": "Including various metaprogramming libraries" + }, + "plotOptions": { + "series": { + "borderWidth": 0, + "dataLabels": { + "enabled": true, + "format": "{point.y:.5f}s" + } + } + }, + "series": [{ + "name": "Include time", + "colorByPoint": true, + "data": [ + { + "name": "Baseline (no includes)", + "y": <%= amortize('baseline.erb.cpp') %> + }, { + "name": "Boost.Hana", + "y": <%= amortize('hana.erb.cpp') %> + } + + <% if cmake_bool("@Boost_FOUND@") %> + , { + "name": "Boost.MPL", + "y": <%= amortize('mpl.erb.cpp') %> + }, { + "name": "Boost.Fusion", + "y": <%= amortize('fusion.erb.cpp') %> + } + <% end %> + + <% if cmake_bool("@MPL11_FOUND@") %> + , { + "name": "MPL11", + "y": <%= amortize('mpl11.erb.cpp') %> + } + <% end %> + + <% if cmake_bool("@Meta_FOUND@") %> + , { + "name": "Meta", + "y": <%= amortize('meta.erb.cpp') %> + } + <% end %> + ] + }] +} diff --git a/src/boost/libs/hana/benchmark/including/fusion.erb.cpp b/src/boost/libs/hana/benchmark/including/fusion.erb.cpp new file mode 100644 index 000000000..bae08353a --- /dev/null +++ b/src/boost/libs/hana/benchmark/including/fusion.erb.cpp @@ -0,0 +1,16 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +int main() { } diff --git a/src/boost/libs/hana/benchmark/including/hana.erb.cpp b/src/boost/libs/hana/benchmark/including/hana.erb.cpp new file mode 100644 index 000000000..e35e81350 --- /dev/null +++ b/src/boost/libs/hana/benchmark/including/hana.erb.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + + +int main() { } diff --git a/src/boost/libs/hana/benchmark/including/meta.erb.cpp b/src/boost/libs/hana/benchmark/including/meta.erb.cpp new file mode 100644 index 000000000..492d2f9ed --- /dev/null +++ b/src/boost/libs/hana/benchmark/including/meta.erb.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + + +int main() { } diff --git a/src/boost/libs/hana/benchmark/including/mpl.erb.cpp b/src/boost/libs/hana/benchmark/including/mpl.erb.cpp new file mode 100644 index 000000000..167eb3765 --- /dev/null +++ b/src/boost/libs/hana/benchmark/including/mpl.erb.cpp @@ -0,0 +1,155 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +int main() { } diff --git a/src/boost/libs/hana/benchmark/including/mpl11.erb.cpp b/src/boost/libs/hana/benchmark/including/mpl11.erb.cpp new file mode 100644 index 000000000..e5b9fd512 --- /dev/null +++ b/src/boost/libs/hana/benchmark/including/mpl11.erb.cpp @@ -0,0 +1,8 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + + +int main() { } diff --git a/src/boost/libs/hana/benchmark/make/compile.erb.json b/src/boost/libs/hana/benchmark/make/compile.erb.json new file mode 100644 index 000000000..24166876d --- /dev/null +++ b/src/boost/libs/hana/benchmark/make/compile.erb.json @@ -0,0 +1,58 @@ +<% + hana = (0...50).step(5).to_a + (50..400).step(25).to_a + fusion = (0...50).step(5).to_a + [50, 75, 100] + mpl = hana + meta = (0...50).step(5).to_a + (50..200).step(25).to_a + mpl11 = hana + std = (0...50).step(5).to_a + (50..100).step(25).to_a +%> + +{ + "title": { + "text": "Compile-time behavior of creating a sequence" + }, + "series": [ + { + "name": "hana::tuple", + "data": <%= time_compilation('compile.hana.tuple.erb.cpp', hana) %> + }, { + "name": "hana::basic_tuple", + "data": <%= time_compilation('compile.hana.basic_tuple.erb.cpp', hana) %> + }, { + "name": "std::array", + "data": <%= time_compilation('compile.std.array.erb.cpp', hana) %> + } + + , { + "name": "std::tuple", + "data": <%= time_compilation('compile.std.tuple.erb.cpp', std) %> + } + + <% if cmake_bool("@Boost_FOUND@") %> + , { + "name": "fusion::vector", + "data": <%= time_compilation('compile.fusion.vector.erb.cpp', fusion) %> + }, { + "name": "fusion::list", + "data": <%= time_compilation('compile.fusion.list.erb.cpp', fusion) %> + }, { + "name": "mpl::vector", + "data": <%= time_compilation('compile.mpl.vector.erb.cpp', mpl) %> + } + <% end %> + + <% if cmake_bool("@Meta_FOUND@") %> + , { + "name": "meta::list", + "data": <%= time_compilation('compile.meta.list.erb.cpp', meta) %> + } + <% end %> + + <% if cmake_bool("@MPL11_FOUND@") %> + , { + "name": "mpl11::list", + "data": <%= time_compilation('compile.mpl11.list.erb.cpp', mpl11) %> + } + <% end %> + ] +} diff --git a/src/boost/libs/hana/benchmark/make/compile.fusion.list.erb.cpp b/src/boost/libs/hana/benchmark/make/compile.fusion.list.erb.cpp new file mode 100644 index 000000000..7274375a8 --- /dev/null +++ b/src/boost/libs/hana/benchmark/make/compile.fusion.list.erb.cpp @@ -0,0 +1,15 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + + +template +struct x { }; + +int main() { + auto xs = <%= fusion_list((1..input_size).map { |n| "x<#{n}>{}" }) %>; + (void)xs; +} diff --git a/src/boost/libs/hana/benchmark/make/compile.fusion.vector.erb.cpp b/src/boost/libs/hana/benchmark/make/compile.fusion.vector.erb.cpp new file mode 100644 index 000000000..fd3794b34 --- /dev/null +++ b/src/boost/libs/hana/benchmark/make/compile.fusion.vector.erb.cpp @@ -0,0 +1,15 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + + +template +struct x { }; + +int main() { + auto vector = <%= fusion_vector((1..input_size).map { |n| "x<#{n}>{}" }) %>; + (void)vector; +} diff --git a/src/boost/libs/hana/benchmark/make/compile.hana.basic_tuple.erb.cpp b/src/boost/libs/hana/benchmark/make/compile.hana.basic_tuple.erb.cpp new file mode 100644 index 000000000..a04016a4c --- /dev/null +++ b/src/boost/libs/hana/benchmark/make/compile.hana.basic_tuple.erb.cpp @@ -0,0 +1,16 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + + +template +struct x { }; + +int main() { + constexpr auto tuple = boost::hana::make_basic_tuple( + <%= (1..input_size).map { |n| "x<#{n}>{}" }.join(', ') %> + ); + (void)tuple; +} diff --git a/src/boost/libs/hana/benchmark/make/compile.hana.tuple.erb.cpp b/src/boost/libs/hana/benchmark/make/compile.hana.tuple.erb.cpp new file mode 100644 index 000000000..34ce368e3 --- /dev/null +++ b/src/boost/libs/hana/benchmark/make/compile.hana.tuple.erb.cpp @@ -0,0 +1,16 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + + +template +struct x { }; + +int main() { + constexpr auto tuple = boost::hana::make_tuple( + <%= (1..input_size).map { |n| "x<#{n}>{}" }.join(', ') %> + ); + (void)tuple; +} diff --git a/src/boost/libs/hana/benchmark/make/compile.meta.list.erb.cpp b/src/boost/libs/hana/benchmark/make/compile.meta.list.erb.cpp new file mode 100644 index 000000000..f90fef99b --- /dev/null +++ b/src/boost/libs/hana/benchmark/make/compile.meta.list.erb.cpp @@ -0,0 +1,17 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + + +template +struct x; + +using list = meta::list< + <%= (1..input_size).map { |i| "x<#{i}>" }.join(', ') %> +>; + +int main() { + +} diff --git a/src/boost/libs/hana/benchmark/make/compile.mpl.vector.erb.cpp b/src/boost/libs/hana/benchmark/make/compile.mpl.vector.erb.cpp new file mode 100644 index 000000000..4b7d94c53 --- /dev/null +++ b/src/boost/libs/hana/benchmark/make/compile.mpl.vector.erb.cpp @@ -0,0 +1,14 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + + +template +struct t { }; + +using vector = <%= mpl_vector((1..input_size).to_a.map { |n| "t<#{n}>" }) %>; + +int main() { } diff --git a/src/boost/libs/hana/benchmark/make/compile.mpl11.list.erb.cpp b/src/boost/libs/hana/benchmark/make/compile.mpl11.list.erb.cpp new file mode 100644 index 000000000..79d0c697d --- /dev/null +++ b/src/boost/libs/hana/benchmark/make/compile.mpl11.list.erb.cpp @@ -0,0 +1,17 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + + +template +struct x; + +using list = boost::mpl11::list< + <%= (1..input_size).map { |i| "x<#{i}>" }.join(', ') %> +>; + +int main() { + +} diff --git a/src/boost/libs/hana/benchmark/make/compile.std.array.erb.cpp b/src/boost/libs/hana/benchmark/make/compile.std.array.erb.cpp new file mode 100644 index 000000000..792ec4848 --- /dev/null +++ b/src/boost/libs/hana/benchmark/make/compile.std.array.erb.cpp @@ -0,0 +1,16 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + + +template +struct x { }; + +int main() { + constexpr std::array> array = {{ + <%= (1..input_size).to_a.join(', ') %> + }}; + (void)array; +} diff --git a/src/boost/libs/hana/benchmark/make/compile.std.tuple.erb.cpp b/src/boost/libs/hana/benchmark/make/compile.std.tuple.erb.cpp new file mode 100644 index 000000000..11fc7cd85 --- /dev/null +++ b/src/boost/libs/hana/benchmark/make/compile.std.tuple.erb.cpp @@ -0,0 +1,16 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + + +template +struct x { }; + +int main() { + constexpr auto tuple = std::make_tuple( + <%= (1..input_size).map { |n| "x<#{n}>{}" }.join(', ') %> + ); + (void)tuple; +} diff --git a/src/boost/libs/hana/benchmark/measure.hpp b/src/boost/libs/hana/benchmark/measure.hpp new file mode 100644 index 000000000..a477fefcf --- /dev/null +++ b/src/boost/libs/hana/benchmark/measure.hpp @@ -0,0 +1,29 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_BENCHMARK_MEASURE_HPP +#define BOOST_HANA_BENCHMARK_MEASURE_HPP + +#include +#include + + +namespace boost { namespace hana { namespace benchmark { + auto measure = [](auto f) { + constexpr auto repetitions = 500ull; + auto start = std::chrono::steady_clock::now(); + for (auto i = repetitions; i > 0; --i) { + f(); + } + auto stop = std::chrono::steady_clock::now(); + + auto time = std::chrono::duration_cast>( + (stop - start) / repetitions + ); + std::cout << std::fixed; + std::cout << "[execution time: " << time.count() << "]" << std::endl; + }; +}}} + +#endif diff --git a/src/boost/libs/hana/benchmark/measure.in.rb b/src/boost/libs/hana/benchmark/measure.in.rb new file mode 100755 index 000000000..65e2a98b4 --- /dev/null +++ b/src/boost/libs/hana/benchmark/measure.in.rb @@ -0,0 +1,161 @@ +#!/usr/bin/env ruby +# +# Copyright Louis Dionne 2013-2017 +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +# +# +# When called as a program, this script runs the command line given in +# arguments and returns the total time. This is similar to the `time` +# command from Bash. +# +# This file can also be required as a Ruby module to gain access to the +# methods defined below. +# +# NOTE: +# This file must not be used as-is. It must be processed by CMake first. + +require 'benchmark' +require 'open3' +require 'pathname' +require 'ruby-progressbar' +require 'tilt' + + +def split_at(n, list) + before = list[0...n] || [] + after = list[n..-1] || [] + return [before, after] +end + +# types : A sequence of strings to put in the mpl::vector. +# Using this method requires including +# - +# - +def mpl_vector(types) + fast, rest = split_at(20, types) + rest.inject("boost::mpl::vector#{fast.length}<#{fast.join(', ')}>") { |v, t| + "boost::mpl::push_back<#{v}, #{t}>::type" + } +end + +# types : A sequence of strings to put in the mpl::list. +# Using this method requires including +# - +# - +def mpl_list(types) + prefix, fast = split_at([types.length - 20, 0].max, types) + prefix.reverse.inject("boost::mpl::list#{fast.length}<#{fast.join(', ')}>") { |l, t| + "boost::mpl::push_front<#{l}, #{t}>::type" + } +end + +# values : A sequence of strings representing values to put in the fusion::vector. +# Using this method requires including +# - +# - +def fusion_vector(values) + fast, rest = split_at(10, values) + rest.inject("boost::fusion::make_vector(#{fast.join(', ')})") { |xs, v| + "boost::fusion::push_back(#{xs}, #{v})" + } +end + +# values : A sequence of strings representing values to put in the fusion::list. +# Using this method requires including +# - +# - +def fusion_list(values) + fast, rest = split_at(10, values) + rest.inject("boost::fusion::make_list(#{fast.join(', ')})") { |xs, v| + "boost::fusion::push_back(#{xs}, #{v})" + } +end + +# Turns a CMake-style boolean into a Ruby boolean. +def cmake_bool(b) + return true if b.is_a? String and ["true", "yes", "1"].include?(b.downcase) + return true if b.is_a? Integer and b > 0 + return false # otherwise +end + +# aspect must be one of :compilation_time, :bloat, :execution_time +def measure(aspect, template_relative, range, env = {}) + measure_file = Pathname.new("#{MEASURE_FILE}") + template = Pathname.new(template_relative).expand_path + range = range.to_a + + if ENV["BOOST_HANA_JUST_CHECK_BENCHMARKS"] && range.length >= 2 + range = [range[0], range[-1]] + end + + make = -> (target) { + command = "@CMAKE_COMMAND@ --build @CMAKE_BINARY_DIR@ --target #{target}" + stdout, stderr, status = Open3.capture3(command) + } + + progress = ProgressBar.create(format: '%p%% %t | %B |', + title: template_relative, + total: range.size, + output: STDERR) + range.map do |n| + # Evaluate the ERB template with the given environment, and save + # the result in the `measure.cpp` file. + code = Tilt::ERBTemplate.new(template).render(nil, input_size: n, env: env) + measure_file.write(code) + + # Compile the file and get timing statistics. The timing statistics + # are output to stdout when we compile the file because of the way + # the `compile.benchmark.measure` CMake target is setup. + stdout, stderr, status = make["#{MEASURE_TARGET}"] + raise "compilation error: #{stdout}\n\n#{stderr}\n\n#{code}" if not status.success? + ctime = stdout.match(/\[compilation time: (.+)\]/i) + # Size of the generated executable in KB + size = File.size("@CMAKE_CURRENT_BINARY_DIR@/#{MEASURE_TARGET}").to_f / 1000 + + # If we didn't match anything, that's because we went too fast, CMake + # did not have the time to see the changes to the measure file and + # the target was not rebuilt. So we sleep for a bit and then retry + # this iteration. + (sleep 0.2; redo) if ctime.nil? + stat = ctime.captures[0].to_f if aspect == :compilation_time + stat = size if aspect == :bloat + + # Run the resulting program and get timing statistics. The statistics + # should be written to stdout by the `measure` function of the + # `measure.hpp` header. + if aspect == :execution_time + stdout, stderr, status = make["#{MEASURE_TARGET}.run"] + raise "runtime error: #{stderr}\n\n#{code}" if not status.success? + match = stdout.match(/\[execution time: (.+)\]/i) + if match.nil? + raise ("Could not find [execution time: ...] bit in the output. " + + "Did you use the `measure` function in the `measure.hpp` header? " + + "stdout follows:\n#{stdout}") + end + stat = match.captures[0].to_f + end + + progress.increment + [n, stat] + end +ensure + measure_file.write("") + progress.finish if progress +end + +def time_execution(erb_file, range, env = {}) + measure(:execution_time, erb_file, range, env) +end + +def time_compilation(erb_file, range, env = {}) + measure(:compilation_time, erb_file, range, env) +end + +if __FILE__ == $0 + command = ARGV.join(' ') + time = Benchmark.realtime { `#{command}` } + + puts "[command line: #{command}]" + puts "[compilation time: #{time}]" +end diff --git a/src/boost/libs/hana/benchmark/reverse/move.erb.json b/src/boost/libs/hana/benchmark/reverse/move.erb.json new file mode 100644 index 000000000..81ab5b7fe --- /dev/null +++ b/src/boost/libs/hana/benchmark/reverse/move.erb.json @@ -0,0 +1,23 @@ +<% + exec = (0..100).step(10).to_a + fusion = (0..50).step(10).to_a +%> + +{ + "title": { + "text": "Runtime performance of reverse on a moved-from container" + }, + "series": [ + { + "name": "hana::tuple", + "data": <%= time_execution('move.hana.tuple.erb.cpp', exec) %> + } + + <% if cmake_bool("@Boost_FOUND@") %> + , { + "name": "fusion::vector", + "data": <%= time_execution('move.fusion.vector.erb.cpp', fusion) %> + } + <% end %> + ] +} diff --git a/src/boost/libs/hana/benchmark/reverse/move.fusion.vector.erb.cpp b/src/boost/libs/hana/benchmark/reverse/move.fusion.vector.erb.cpp new file mode 100644 index 000000000..83c293712 --- /dev/null +++ b/src/boost/libs/hana/benchmark/reverse/move.fusion.vector.erb.cpp @@ -0,0 +1,33 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +<% if input_size > 10 %> + #define FUSION_MAX_VECTOR_SIZE <%= ((input_size + 9) / 10) * 10 %> +<% end %> + +#include +#include +#include + +#include "measure.hpp" +#include +#include +#include +namespace fusion = boost::fusion; +namespace hana = boost::hana; + + +int main () { + std::string s(1000, 'x'); + hana::benchmark::measure([&] { + for (int iteration = 0; iteration < 1 << 5; ++iteration) { + auto values = fusion::make_vector( + <%= input_size.times.map { 's' }.join(', ') %> + ); + + auto result = fusion::as_vector(fusion::reverse(std::move(values))); + (void)result; + } + }); +} diff --git a/src/boost/libs/hana/benchmark/reverse/move.hana.tuple.erb.cpp b/src/boost/libs/hana/benchmark/reverse/move.hana.tuple.erb.cpp new file mode 100644 index 000000000..bf27357d5 --- /dev/null +++ b/src/boost/libs/hana/benchmark/reverse/move.hana.tuple.erb.cpp @@ -0,0 +1,27 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include "measure.hpp" +#include +#include +#include +namespace hana = boost::hana; + + +int main () { + std::string s(1000, 'x'); + hana::benchmark::measure([&] { + for (int iteration = 0; iteration < 1 << 5; ++iteration) { + auto values = hana::make_tuple( + <%= input_size.times.map { 's' }.join(', ') %> + ); + + auto result = hana::reverse(std::move(values)); + (void)result; + } + }); +} diff --git a/src/boost/libs/hana/benchmark/reverse/nomove.erb.json b/src/boost/libs/hana/benchmark/reverse/nomove.erb.json new file mode 100644 index 000000000..b9d39bd85 --- /dev/null +++ b/src/boost/libs/hana/benchmark/reverse/nomove.erb.json @@ -0,0 +1,23 @@ +<% + exec = (0..100).step(10).to_a + fusion = (0..50).step(10).to_a +%> + +{ + "title": { + "text": "Runtime performance of reverse on a normal container" + }, + "series": [ + { + "name": "hana::tuple", + "data": <%= time_execution('nomove.hana.tuple.erb.cpp', exec) %> + } + + <% if cmake_bool("@Boost_FOUND@") %> + , { + "name": "fusion::vector", + "data": <%= time_execution('nomove.fusion.vector.erb.cpp', fusion) %> + } + <% end %> + ] +} diff --git a/src/boost/libs/hana/benchmark/reverse/nomove.fusion.vector.erb.cpp b/src/boost/libs/hana/benchmark/reverse/nomove.fusion.vector.erb.cpp new file mode 100644 index 000000000..cbb4b07d2 --- /dev/null +++ b/src/boost/libs/hana/benchmark/reverse/nomove.fusion.vector.erb.cpp @@ -0,0 +1,33 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +<% if input_size > 10 %> + #define FUSION_MAX_VECTOR_SIZE <%= ((input_size + 9) / 10) * 10 %> +<% end %> + +#include +#include +#include + +#include "measure.hpp" +#include +#include +#include +namespace fusion = boost::fusion; +namespace hana = boost::hana; + + +int main () { + std::string s(1000, 'x'); + hana::benchmark::measure([&] { + for (int iteration = 0; iteration < 1 << 5; ++iteration) { + auto values = fusion::make_vector( + <%= input_size.times.map { 's' }.join(', ') %> + ); + + auto result = fusion::as_vector(fusion::reverse(values)); + (void)result; + } + }); +} diff --git a/src/boost/libs/hana/benchmark/reverse/nomove.hana.tuple.erb.cpp b/src/boost/libs/hana/benchmark/reverse/nomove.hana.tuple.erb.cpp new file mode 100644 index 000000000..913061e3d --- /dev/null +++ b/src/boost/libs/hana/benchmark/reverse/nomove.hana.tuple.erb.cpp @@ -0,0 +1,27 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include "measure.hpp" +#include +#include +#include +namespace hana = boost::hana; + + +int main () { + std::string s(1000, 'x'); + hana::benchmark::measure([&] { + for (int iteration = 0; iteration < 1 << 5; ++iteration) { + auto values = hana::make_tuple( + <%= input_size.times.map { 's' }.join(', ') %> + ); + + auto result = hana::reverse(values); + (void)result; + } + }); +} diff --git a/src/boost/libs/hana/benchmark/sort/compile.erb.json b/src/boost/libs/hana/benchmark/sort/compile.erb.json new file mode 100644 index 000000000..1a13543bc --- /dev/null +++ b/src/boost/libs/hana/benchmark/sort/compile.erb.json @@ -0,0 +1,31 @@ +<% + hana = [0, 1, 2, 5, 10, 20, 50, 100] +%> + +{ + "title": { + "text": "Compile-time behavior of sort" + }, + "series": [ + { + "name": "hana::tuple::sorted", + "data": <%= time_compilation('compile.hana.tuple.sorted.erb.cpp', hana) %> + }, + { + "name": "hana::tuple::reversed", + "data": <%= time_compilation('compile.hana.tuple.reversed.erb.cpp', hana) %> + }, + { + "name": "hana::tuple::rand", + "data": <%= time_compilation('compile.hana.tuple.rand.erb.cpp', hana) %> + }, + { + "name": "hana::tuple::sorted_but_first", + "data": <%= time_compilation('compile.hana.tuple.sorted_but_first.erb.cpp', hana) %> + }, + { + "name": "hana::tuple::sorted_but_last", + "data": <%= time_compilation('compile.hana.tuple.sorted_but_last.erb.cpp', hana) %> + } + ] +} diff --git a/src/boost/libs/hana/benchmark/sort/compile.hana.tuple.rand.erb.cpp b/src/boost/libs/hana/benchmark/sort/compile.hana.tuple.rand.erb.cpp new file mode 100644 index 000000000..771a1ffaf --- /dev/null +++ b/src/boost/libs/hana/benchmark/sort/compile.hana.tuple.rand.erb.cpp @@ -0,0 +1,14 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +int main() { + constexpr auto tuple = boost::hana::make_tuple( + <%= (1..input_size).to_a.shuffle.map { |n| "boost::hana::int_c<#{n}>" }.join(', ') %> + ); + constexpr auto result = boost::hana::sort(tuple); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/sort/compile.hana.tuple.reversed.erb.cpp b/src/boost/libs/hana/benchmark/sort/compile.hana.tuple.reversed.erb.cpp new file mode 100644 index 000000000..6fc85758f --- /dev/null +++ b/src/boost/libs/hana/benchmark/sort/compile.hana.tuple.reversed.erb.cpp @@ -0,0 +1,14 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +int main() { + constexpr auto tuple = boost::hana::make_tuple( + <%= (1..input_size).to_a.reverse.map { |n| "boost::hana::int_c<#{n}>" }.join(', ') %> + ); + constexpr auto result = boost::hana::sort(tuple); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/sort/compile.hana.tuple.sorted.erb.cpp b/src/boost/libs/hana/benchmark/sort/compile.hana.tuple.sorted.erb.cpp new file mode 100644 index 000000000..c48becf05 --- /dev/null +++ b/src/boost/libs/hana/benchmark/sort/compile.hana.tuple.sorted.erb.cpp @@ -0,0 +1,14 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +int main() { + constexpr auto tuple = boost::hana::make_tuple( + <%= (1..input_size).map { |n| "boost::hana::int_c<#{n}>" }.join(', ') %> + ); + constexpr auto result = boost::hana::sort(tuple); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/sort/compile.hana.tuple.sorted_but_first.erb.cpp b/src/boost/libs/hana/benchmark/sort/compile.hana.tuple.sorted_but_first.erb.cpp new file mode 100644 index 000000000..14795621f --- /dev/null +++ b/src/boost/libs/hana/benchmark/sort/compile.hana.tuple.sorted_but_first.erb.cpp @@ -0,0 +1,14 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +int main() { + constexpr auto tuple = boost::hana::make_tuple( + <%= ([input_size+1] + (1..input_size).to_a).map { |n| "boost::hana::int_c<#{n}>" }.join(', ') %> + ); + constexpr auto result = boost::hana::sort(tuple); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/sort/compile.hana.tuple.sorted_but_last.erb.cpp b/src/boost/libs/hana/benchmark/sort/compile.hana.tuple.sorted_but_last.erb.cpp new file mode 100644 index 000000000..5ed14ab7c --- /dev/null +++ b/src/boost/libs/hana/benchmark/sort/compile.hana.tuple.sorted_but_last.erb.cpp @@ -0,0 +1,14 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +int main() { + constexpr auto tuple = boost::hana::make_tuple( + <%= ((1..input_size).to_a + [0]).map { |n| "boost::hana::int_c<#{n}>" }.join(', ') %> + ); + constexpr auto result = boost::hana::sort(tuple); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/transform/bloat.erb.json b/src/boost/libs/hana/benchmark/transform/bloat.erb.json new file mode 100644 index 000000000..62cbdd7ab --- /dev/null +++ b/src/boost/libs/hana/benchmark/transform/bloat.erb.json @@ -0,0 +1,42 @@ +<% + exec = (0..100).step(10).to_a + fusion = (0..50).step(10).to_a +%> + +{ + "title": { + "text": "Executable size for transform" + }, + "yAxis": { + "title": { + "text": "Executable size (kb)" + }, + "floor": 0 + }, + "tooltip": { + "valueSuffix": "kb" + }, + "series": [ + { + "name": "hana::tuple", + "data": <%= measure(:bloat, 'execute.hana.tuple.erb.cpp', exec) %> + } + + , { + "name": "std::array", + "data": <%= measure(:bloat, 'execute.std.array.erb.cpp', exec) %> + } + + , { + "name": "std::vector", + "data": <%= measure(:bloat, 'execute.std.vector.erb.cpp', exec) %> + } + + <% if cmake_bool("@Boost_FOUND@") %> + , { + "name": "fusion::vector", + "data": <%= measure(:bloat, 'execute.fusion.vector.erb.cpp', fusion) %> + } + <% end %> + ] +} \ No newline at end of file diff --git a/src/boost/libs/hana/benchmark/transform/compile.erb.json b/src/boost/libs/hana/benchmark/transform/compile.erb.json new file mode 100644 index 000000000..9036ab49c --- /dev/null +++ b/src/boost/libs/hana/benchmark/transform/compile.erb.json @@ -0,0 +1,49 @@ +<% + hana = (0...50).step(5).to_a + (50..400).step(25).to_a + fusion = (0..50).step(5) + mpl = hana + meta = hana + mpl11 = hana +%> + +{ + "title": { + "text": "Compile-time behavior of transform" + }, + "series": [ + { + "name": "hana::tuple", + "data": <%= time_compilation('compile.hana.tuple.erb.cpp', hana) %> + }, { + "name": "hana::types", + "data": <%= time_compilation('compile.hana.types.erb.cpp', hana) %> + } + + <% if cmake_bool("@Boost_FOUND@") %> + , { + "name": "mpl::vector", + "data": <%= time_compilation('compile.mpl.vector.erb.cpp', mpl) %> + }, { + "name": "fusion::vector", + "data": <%= time_compilation('compile.fusion.vector.erb.cpp', fusion) %> + }, { + "name": "fusion::list", + "data": <%= time_compilation('compile.fusion.list.erb.cpp', fusion) %> + } + <% end %> + + <% if cmake_bool("@Meta_FOUND@") %> + , { + "name": "meta::list", + "data": <%= time_compilation('compile.meta.list.erb.cpp', meta) %> + } + <% end %> + + <% if cmake_bool("@MPL11_FOUND@") %> + , { + "name": "mpl11::list", + "data": <%= time_compilation('compile.mpl11.list.erb.cpp', mpl11) %> + } + <% end %> + ] +} diff --git a/src/boost/libs/hana/benchmark/transform/compile.fusion.list.erb.cpp b/src/boost/libs/hana/benchmark/transform/compile.fusion.list.erb.cpp new file mode 100644 index 000000000..4ced955d5 --- /dev/null +++ b/src/boost/libs/hana/benchmark/transform/compile.fusion.list.erb.cpp @@ -0,0 +1,30 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +<% if input_size > 10 %> + #define FUSION_MAX_LIST_SIZE <%= ((input_size + 9) / 10) * 10 %> +<% end %> + +#include +#include +#include +namespace fusion = boost::fusion; + + +struct f { + template + constexpr X operator()(X x) const { return x; } +}; + +template +struct x { }; + +int main() { + auto xs = fusion::make_list( + <%= (1..input_size).map { |n| "x<#{n}>{}" }.join(', ') %> + ); + + auto result = fusion::as_list(fusion::transform(xs, f{})); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/transform/compile.fusion.vector.erb.cpp b/src/boost/libs/hana/benchmark/transform/compile.fusion.vector.erb.cpp new file mode 100644 index 000000000..687e7b510 --- /dev/null +++ b/src/boost/libs/hana/benchmark/transform/compile.fusion.vector.erb.cpp @@ -0,0 +1,30 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +<% if input_size > 10 %> + #define FUSION_MAX_VECTOR_SIZE <%= ((input_size + 9) / 10) * 10 %> +<% end %> + +#include +#include +#include +namespace fusion = boost::fusion; + + +struct f { + template + constexpr X operator()(X x) const { return x; } +}; + +template +struct x { }; + +int main() { + auto xs = fusion::make_vector( + <%= (1..input_size).map { |n| "x<#{n}>{}" }.join(', ') %> + ); + + auto result = fusion::as_vector(fusion::transform(xs, f{})); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/transform/compile.hana.tuple.erb.cpp b/src/boost/libs/hana/benchmark/transform/compile.hana.tuple.erb.cpp new file mode 100644 index 000000000..0d3c8951d --- /dev/null +++ b/src/boost/libs/hana/benchmark/transform/compile.hana.tuple.erb.cpp @@ -0,0 +1,23 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + + +struct f { + template + constexpr X operator()(X x) const { return x; } +}; + +template +struct x { }; + +int main() { + constexpr auto tuple = boost::hana::make_tuple( + <%= (1..input_size).map { |n| "x<#{n}>{}" }.join(', ') %> + ); + constexpr auto result = boost::hana::transform(tuple, f{}); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/transform/compile.hana.types.erb.cpp b/src/boost/libs/hana/benchmark/transform/compile.hana.types.erb.cpp new file mode 100644 index 000000000..0ad755699 --- /dev/null +++ b/src/boost/libs/hana/benchmark/transform/compile.hana.types.erb.cpp @@ -0,0 +1,26 @@ +/* +@copyright Louis Dionne 2015 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include +#include +#include +namespace hana = boost::hana; + + +template +struct f { struct type; }; + +template struct x; + + +int main() { + constexpr auto types = hana::experimental::types< + <%= (1..input_size).map { |i| "x<#{i}>" }.join(', ') %> + >{}; + + constexpr auto result = hana::transform(types, hana::metafunction); + (void)result; +} diff --git a/src/boost/libs/hana/benchmark/transform/compile.meta.list.erb.cpp b/src/boost/libs/hana/benchmark/transform/compile.meta.list.erb.cpp new file mode 100644 index 000000000..1341cccb4 --- /dev/null +++ b/src/boost/libs/hana/benchmark/transform/compile.meta.list.erb.cpp @@ -0,0 +1,23 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + + +struct f { + template + struct apply; +}; + +template struct x; + +using list = meta::list< + <%= (1..input_size).map { |i| "x<#{i}>" }.join(', ') %> +>; + +using result = meta::transform; + +int main() { + +} diff --git a/src/boost/libs/hana/benchmark/transform/compile.mpl.vector.erb.cpp b/src/boost/libs/hana/benchmark/transform/compile.mpl.vector.erb.cpp new file mode 100644 index 000000000..a7bdc72d8 --- /dev/null +++ b/src/boost/libs/hana/benchmark/transform/compile.mpl.vector.erb.cpp @@ -0,0 +1,22 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + + +template +struct f { using type = X; }; + +template +struct t { }; + +using vector = <%= mpl_vector((1..input_size).to_a.map { |n| "t<#{n}>" }) %>; + +using result = boost::mpl::transform>::type; + + +int main() { } diff --git a/src/boost/libs/hana/benchmark/transform/compile.mpl11.list.erb.cpp b/src/boost/libs/hana/benchmark/transform/compile.mpl11.list.erb.cpp new file mode 100644 index 000000000..262e48bc0 --- /dev/null +++ b/src/boost/libs/hana/benchmark/transform/compile.mpl11.list.erb.cpp @@ -0,0 +1,24 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + + +struct f { + using type = f; + template + struct apply { struct type; }; +}; + +template struct x { struct type; }; + +using list = boost::mpl11::list< + <%= (1..input_size).map { |i| "x<#{i}>" }.join(', ') %> +>; + +using result = boost::mpl11::fmap::type; + +int main() { + +} diff --git a/src/boost/libs/hana/benchmark/transform/execute.erb.json b/src/boost/libs/hana/benchmark/transform/execute.erb.json new file mode 100644 index 000000000..98738317e --- /dev/null +++ b/src/boost/libs/hana/benchmark/transform/execute.erb.json @@ -0,0 +1,36 @@ +<% + exec = (0..100).step(10).to_a + fusion = (0..50).step(10).to_a +%> + +{ + "title": { + "text": "Runtime behavior of transform" + }, + "series": [ + { + "name": "hana::tuple", + "data": <%= time_execution('execute.hana.tuple.erb.cpp', exec) %> + } + + , { + "name": "std::array", + "data": <%= time_execution('execute.std.array.erb.cpp', exec) %> + } + + , { + "name": "std::vector", + "data": <%= time_execution('execute.std.vector.erb.cpp', exec) %> + } + + <% if cmake_bool("@Boost_FOUND@") %> + , { + "name": "fusion::vector", + "data": <%= time_execution('execute.fusion.vector.erb.cpp', fusion) %> + }, { + "name": "fusion::list", + "data": <%= time_execution('execute.fusion.list.erb.cpp', fusion) %> + } + <% end %> + ] +} diff --git a/src/boost/libs/hana/benchmark/transform/execute.fusion.list.erb.cpp b/src/boost/libs/hana/benchmark/transform/execute.fusion.list.erb.cpp new file mode 100644 index 000000000..5855a61da --- /dev/null +++ b/src/boost/libs/hana/benchmark/transform/execute.fusion.list.erb.cpp @@ -0,0 +1,33 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +<% if input_size > 10 %> + #define FUSION_MAX_LIST_SIZE <%= ((input_size + 9) / 10) * 10 %> +<% end %> + +#include +#include +#include + +#include "measure.hpp" +#include +namespace fusion = boost::fusion; +namespace hana = boost::hana; + + +int main () { + hana::benchmark::measure([] { + long long result = 0; + for (int iteration = 0; iteration < 1 << 10; ++iteration) { + auto values = fusion::make_list( + <%= input_size.times.map { 'std::rand()' }.join(', ') %> + ); + + auto transformed = fusion::as_list(fusion::transform(values, [&](auto t) { + return result += t; + })); + (void)transformed; + } + }); +} diff --git a/src/boost/libs/hana/benchmark/transform/execute.fusion.vector.erb.cpp b/src/boost/libs/hana/benchmark/transform/execute.fusion.vector.erb.cpp new file mode 100644 index 000000000..721a35f24 --- /dev/null +++ b/src/boost/libs/hana/benchmark/transform/execute.fusion.vector.erb.cpp @@ -0,0 +1,33 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +<% if input_size > 10 %> + #define FUSION_MAX_VECTOR_SIZE <%= ((input_size + 9) / 10) * 10 %> +<% end %> + +#include +#include +#include + +#include "measure.hpp" +#include +namespace fusion = boost::fusion; +namespace hana = boost::hana; + + +int main () { + hana::benchmark::measure([] { + long long result = 0; + for (int iteration = 0; iteration < 1 << 10; ++iteration) { + auto values = fusion::make_vector( + <%= input_size.times.map { 'std::rand()' }.join(', ') %> + ); + + auto transformed = fusion::as_vector(fusion::transform(values, [&](auto t) { + return result += t; + })); + (void)transformed; + } + }); +} diff --git a/src/boost/libs/hana/benchmark/transform/execute.hana.tuple.erb.cpp b/src/boost/libs/hana/benchmark/transform/execute.hana.tuple.erb.cpp new file mode 100644 index 000000000..8d58e1938 --- /dev/null +++ b/src/boost/libs/hana/benchmark/transform/execute.hana.tuple.erb.cpp @@ -0,0 +1,26 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include "measure.hpp" +#include + + +int main () { + boost::hana::benchmark::measure([] { + long long result = 0; + for (int iteration = 0; iteration < 1 << 10; ++iteration) { + auto values = boost::hana::make_tuple( + <%= input_size.times.map { 'std::rand()' }.join(', ') %> + ); + + auto transformed = boost::hana::transform(values, [&](auto t) { + return result += t; + }); + (void)transformed; + } + }); +} diff --git a/src/boost/libs/hana/benchmark/transform/execute.std.array.erb.cpp b/src/boost/libs/hana/benchmark/transform/execute.std.array.erb.cpp new file mode 100644 index 000000000..f5537be40 --- /dev/null +++ b/src/boost/libs/hana/benchmark/transform/execute.std.array.erb.cpp @@ -0,0 +1,26 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "measure.hpp" +#include +#include +#include + + +int main () { + boost::hana::benchmark::measure([] { + long long result = 0; + for (int iteration = 0; iteration < 1 << 10; ++iteration) { + std::array> values = {{ + <%= input_size.times.map { 'std::rand()' }.join(', ') %> + }}; + + std::array> results{}; + + std::transform(values.begin(), values.end(), results.begin(), [&](auto t) { + return result += t; + }); + } + }); +} diff --git a/src/boost/libs/hana/benchmark/transform/execute.std.vector.erb.cpp b/src/boost/libs/hana/benchmark/transform/execute.std.vector.erb.cpp new file mode 100644 index 000000000..5b6b11d75 --- /dev/null +++ b/src/boost/libs/hana/benchmark/transform/execute.std.vector.erb.cpp @@ -0,0 +1,27 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include "measure.hpp" +#include +#include +#include + + +int main () { + boost::hana::benchmark::measure([] { + long long result = 0; + for (int iteration = 0; iteration < 1 << 10; ++iteration) { + std::vector values = { + <%= input_size.times.map { 'std::rand()' }.join(', ') %> + }; + + std::vector results; + results.reserve(<%= input_size %>); + + std::transform(values.begin(), values.end(), results.begin(), [&](auto t) { + return result += t; + }); + } + }); +} -- cgit v1.2.3