execute.fusion.vector.erb.cpp 1012 B

123456789101112131415161718192021222324252627282930313233
  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. <% if input_size > 10 %>
  5. #define FUSION_MAX_VECTOR_SIZE <%= ((input_size + 9) / 10) * 10 %>
  6. <% end %>
  7. #include <boost/fusion/include/as_vector.hpp>
  8. #include <boost/fusion/include/make_vector.hpp>
  9. #include <boost/fusion/include/transform.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 long result = 0;
  17. for (int iteration = 0; iteration < 1 << 10; ++iteration) {
  18. auto values = fusion::make_vector(
  19. <%= input_size.times.map { 'std::rand()' }.join(', ') %>
  20. );
  21. auto transformed = fusion::as_vector(fusion::transform(values, [&](auto t) {
  22. return result += t;
  23. }));
  24. (void)transformed;
  25. }
  26. });
  27. }