execute.fusion.list.erb.cpp 934 B

1234567891011121314151617181920212223242526272829303132
  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. <% if input_size > 10 %>
  6. #define FUSION_MAX_LIST_SIZE <%= ((input_size + 9) / 10) * 10 %>
  7. <% end %>
  8. #include <boost/fusion/include/fold.hpp>
  9. #include <boost/fusion/include/make_list.hpp>
  10. #include "measure.hpp"
  11. #include <cstdlib>
  12. namespace fusion = boost::fusion;
  13. namespace hana = boost::hana;
  14. int main () {
  15. hana::benchmark::measure([] {
  16. long double result = 0;
  17. for (int iteration = 0; iteration < 1 << 10; ++iteration) {
  18. auto values = fusion::make_list(
  19. <%= input_size.times.map { 'std::rand()' }.join(', ') %>
  20. );
  21. result += fusion::fold(values, 0, [](auto state, auto t) {
  22. return state + t;
  23. });
  24. }
  25. });
  26. }