execute.hana.tuple.erb.cpp 769 B

1234567891011121314151617181920212223242526
  1. // Copyright Louis Dionne 2013-2017
  2. // Copyright Zach Laine 2014
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  5. #include <boost/hana/fold_left.hpp>
  6. #include <boost/hana/tuple.hpp>
  7. #include "measure.hpp"
  8. #include <cstdlib>
  9. int main () {
  10. boost::hana::benchmark::measure([] {
  11. long double result = 0;
  12. for (int iteration = 0; iteration < 1 << 10; ++iteration) {
  13. auto values = boost::hana::make_tuple(
  14. <%= input_size.times.map { 'std::rand()' }.join(', ') %>
  15. );
  16. result += boost::hana::fold_left(values, 0, [](auto state, auto t) {
  17. return state + t;
  18. });
  19. }
  20. });
  21. }