execute.std.array.erb.cpp 655 B

12345678910111213141516171819202122
  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. #include "measure.hpp"
  5. #include <array>
  6. #include <cstdlib>
  7. #include <numeric>
  8. int main () {
  9. boost::hana::benchmark::measure([] {
  10. long long result = 0;
  11. for (int iteration = 0; iteration < 1 << 10; ++iteration) {
  12. std::array<int, <%= input_size %>> values = {{
  13. <%= input_size.times.map { 'std::rand()' }.join(', ') %>
  14. }};
  15. result += std::accumulate(values.begin(), values.end(), 0);
  16. }
  17. });
  18. }