execute.std.array.erb.cpp 790 B

1234567891011121314151617181920212223242526
  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 <algorithm>
  6. #include <array>
  7. #include <cstdlib>
  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. std::array<long long, <%= input_size %>> results{};
  16. std::transform(values.begin(), values.end(), results.begin(), [&](auto t) {
  17. return result += t;
  18. });
  19. }
  20. });
  21. }