summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/hana/benchmark/transform/execute.std.vector.erb.cpp
blob: 5b6b11d75c03bc21fc3960dff886ee71c8192dc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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;
            });
        }
    });
}