diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/hana/benchmark/find_if | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/hana/benchmark/find_if')
9 files changed, 266 insertions, 0 deletions
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 <boost/fusion/include/find_if.hpp> +#include <boost/fusion/include/make_list.hpp> +#include <boost/mpl/integral_c.hpp> +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + + +struct is_last { + template <typename N> + struct apply + : mpl::integral_c<bool, N::type::value == <%= input_size %>> + { }; +}; + +int main() { + auto ints = fusion::make_list( + <%= (1..input_size).map { |n| "mpl::integral_c<int, #{n}>{}" }.join(', ') %> + ); + + auto result = fusion::find_if<is_last>(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 <boost/fusion/include/find_if.hpp> +#include <boost/fusion/include/make_vector.hpp> +#include <boost/mpl/integral_c.hpp> +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + + +struct is_last { + template <typename N> + struct apply + : mpl::integral_c<bool, N::type::value == <%= input_size %>> + { }; +}; + +int main() { + auto ints = fusion::make_vector( + <%= (1..input_size).map { |n| "mpl::integral_c<int, #{n}>{}" }.join(', ') %> + ); + + auto result = fusion::find_if<is_last>(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 <boost/hana/bool.hpp> +#include <boost/hana/find_if.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/map.hpp> +namespace hana = boost::hana; + + +struct is_last { + template <typename N> + constexpr auto operator()(N) const { + return hana::bool_c<N::value == <%= input_size %>>; + } +}; + +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 <boost/hana/bool.hpp> +#include <boost/hana/find_if.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/set.hpp> +namespace hana = boost::hana; + + +struct is_last { + template <typename N> + constexpr auto operator()(N) const { + return hana::bool_c<N::value == <%= input_size %>>; + } +}; + +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 <boost/hana/bool.hpp> +#include <boost/hana/find_if.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/tuple.hpp> + + +struct is_last { + template <typename N> + constexpr auto operator()(N) const { + return boost::hana::bool_c<N::value == <%= input_size %>>; + } +}; + +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 <meta/meta.hpp> + + +struct is_last { + template <typename N> + using apply = meta::bool_<N::value == <%= input_size %>>; +}; + +using list = meta::list< + <%= (1..input_size).map { |i| "meta::int_<#{i}>" }.join(', ') %> +>; + +using result = meta::find_if<list, is_last>; + +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 <boost/mpl/find_if.hpp> +#include <boost/mpl/integral_c.hpp> +#include <boost/mpl/push_back.hpp> +#include <boost/mpl/quote.hpp> +#include <boost/mpl/vector.hpp> +namespace mpl = boost::mpl; + + +struct is_last { + template <typename N> + struct apply + : mpl::integral_c<bool, N::type::value == <%= input_size %>> + { }; +}; + +using vector = <%= mpl_vector((1..input_size).to_a.map { |n| + "mpl::integral_c<int, #{n}>" +}) %>; + +using result = mpl::find_if<vector, is_last>::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 <boost/hana/bool.hpp> +#include <boost/hana/ext/std/integer_sequence.hpp> +#include <boost/hana/find_if.hpp> +#include <boost/hana/integral_constant.hpp> + +#include <utility> +namespace hana = boost::hana; + + +struct is_last { + template <typename N> + constexpr auto operator()(N) const { + return hana::bool_c<N::value == <%= input_size %>>; + } +}; + +int main() { + auto sequence = std::integer_sequence< + <%= (["int"] + (1..input_size).to_a).join(', ') %> + >{}; + auto result = hana::find_if(sequence, is_last{}); + (void)result; +} |