Imported Upstream version 1.64.0
[platform/upstream/boost.git] / libs / hana / benchmark / transform / execute.std.array.erb.cpp
1 // Copyright Louis Dionne 2013-2017
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
4
5 #include "measure.hpp"
6 #include <algorithm>
7 #include <array>
8 #include <cstdlib>
9
10
11 int main () {
12     boost::hana::benchmark::measure([] {
13         long long result = 0;
14         for (int iteration = 0; iteration < 1 << 10; ++iteration) {
15             std::array<int, <%= input_size %>> values = {{
16                 <%= input_size.times.map { 'std::rand()' }.join(', ') %>
17             }};
18
19             std::array<long long, <%= input_size %>> results{};
20
21             std::transform(values.begin(), values.end(), results.begin(), [&](auto t) {
22                 return result += t;
23             });
24         }
25     });
26 }