summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/hana/benchmark/transform
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/hana/benchmark/transform
parentInitial commit. (diff)
downloadceph-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/transform')
-rw-r--r--src/boost/libs/hana/benchmark/transform/bloat.erb.json42
-rw-r--r--src/boost/libs/hana/benchmark/transform/compile.erb.json49
-rw-r--r--src/boost/libs/hana/benchmark/transform/compile.fusion.list.erb.cpp30
-rw-r--r--src/boost/libs/hana/benchmark/transform/compile.fusion.vector.erb.cpp30
-rw-r--r--src/boost/libs/hana/benchmark/transform/compile.hana.tuple.erb.cpp23
-rw-r--r--src/boost/libs/hana/benchmark/transform/compile.hana.types.erb.cpp26
-rw-r--r--src/boost/libs/hana/benchmark/transform/compile.meta.list.erb.cpp23
-rw-r--r--src/boost/libs/hana/benchmark/transform/compile.mpl.vector.erb.cpp22
-rw-r--r--src/boost/libs/hana/benchmark/transform/compile.mpl11.list.erb.cpp24
-rw-r--r--src/boost/libs/hana/benchmark/transform/execute.erb.json36
-rw-r--r--src/boost/libs/hana/benchmark/transform/execute.fusion.list.erb.cpp33
-rw-r--r--src/boost/libs/hana/benchmark/transform/execute.fusion.vector.erb.cpp33
-rw-r--r--src/boost/libs/hana/benchmark/transform/execute.hana.tuple.erb.cpp26
-rw-r--r--src/boost/libs/hana/benchmark/transform/execute.std.array.erb.cpp26
-rw-r--r--src/boost/libs/hana/benchmark/transform/execute.std.vector.erb.cpp27
15 files changed, 450 insertions, 0 deletions
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 <boost/fusion/include/as_list.hpp>
+#include <boost/fusion/include/make_list.hpp>
+#include <boost/fusion/include/transform.hpp>
+namespace fusion = boost::fusion;
+
+
+struct f {
+ template <typename X>
+ constexpr X operator()(X x) const { return x; }
+};
+
+template <int i>
+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 <boost/fusion/include/as_vector.hpp>
+#include <boost/fusion/include/make_vector.hpp>
+#include <boost/fusion/include/transform.hpp>
+namespace fusion = boost::fusion;
+
+
+struct f {
+ template <typename X>
+ constexpr X operator()(X x) const { return x; }
+};
+
+template <int i>
+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 <boost/hana/transform.hpp>
+#include <boost/hana/tuple.hpp>
+
+
+struct f {
+ template <typename X>
+ constexpr X operator()(X x) const { return x; }
+};
+
+template <int i>
+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 <boost/hana/experimental/types.hpp>
+#include <boost/hana/transform.hpp>
+#include <boost/hana/type.hpp>
+namespace hana = boost::hana;
+
+
+template <typename>
+struct f { struct type; };
+
+template <int> 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<f>);
+ (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 <meta/meta.hpp>
+
+
+struct f {
+ template <typename>
+ struct apply;
+};
+
+template <int> struct x;
+
+using list = meta::list<
+ <%= (1..input_size).map { |i| "x<#{i}>" }.join(', ') %>
+>;
+
+using result = meta::transform<list, f>;
+
+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 <boost/mpl/push_back.hpp>
+#include <boost/mpl/quote.hpp>
+#include <boost/mpl/transform.hpp>
+#include <boost/mpl/vector.hpp>
+
+
+template <typename X>
+struct f { using type = X; };
+
+template <int i>
+struct t { };
+
+using vector = <%= mpl_vector((1..input_size).to_a.map { |n| "t<#{n}>" }) %>;
+
+using result = boost::mpl::transform<vector, boost::mpl::quote1<f>>::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 <boost/mpl11/list.hpp>
+
+
+struct f {
+ using type = f;
+ template <typename>
+ struct apply { struct type; };
+};
+
+template <int> struct x { struct type; };
+
+using list = boost::mpl11::list<
+ <%= (1..input_size).map { |i| "x<#{i}>" }.join(', ') %>
+>;
+
+using result = boost::mpl11::fmap<f, list>::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 <boost/fusion/include/as_list.hpp>
+#include <boost/fusion/include/make_list.hpp>
+#include <boost/fusion/include/transform.hpp>
+
+#include "measure.hpp"
+#include <cstdlib>
+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 <boost/fusion/include/as_vector.hpp>
+#include <boost/fusion/include/make_vector.hpp>
+#include <boost/fusion/include/transform.hpp>
+
+#include "measure.hpp"
+#include <cstdlib>
+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 <boost/hana/transform.hpp>
+#include <boost/hana/tuple.hpp>
+
+#include "measure.hpp"
+#include <cstdlib>
+
+
+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 <algorithm>
+#include <array>
+#include <cstdlib>
+
+
+int main () {
+ boost::hana::benchmark::measure([] {
+ long long result = 0;
+ for (int iteration = 0; iteration < 1 << 10; ++iteration) {
+ std::array<int, <%= input_size %>> values = {{
+ <%= input_size.times.map { 'std::rand()' }.join(', ') %>
+ }};
+
+ std::array<long long, <%= input_size %>> 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 <algorithm>
+#include <cstdlib>
+#include <vector>
+
+
+int main () {
+ boost::hana::benchmark::measure([] {
+ long long result = 0;
+ for (int iteration = 0; iteration < 1 << 10; ++iteration) {
+ std::vector<int> values = {
+ <%= input_size.times.map { 'std::rand()' }.join(', ') %>
+ };
+
+ std::vector<long long> results;
+ results.reserve(<%= input_size %>);
+
+ std::transform(values.begin(), values.end(), results.begin(), [&](auto t) {
+ return result += t;
+ });
+ }
+ });
+}