10#ifndef MCRL2_ATERMPP_BENCHMARK_BENCHMARK_SHARED_H
11#define MCRL2_ATERMPP_BENCHMARK_BENCHMARK_SHARED_H
13#include "mcrl2/atermpp/aterm.h"
14#include "mcrl2/utilities/stopwatch.h"
28 assert(number_of_threads >= 1);
35 std::vector<std::jthread> threads(number_of_threads - 1);
37 for (
auto& thread : threads)
39 thread = std::jthread(f, id);
47 for (
auto& thread : threads)
52 std::cerr <<
"time: " << timer.seconds() << std::endl;
56template<
bool with_converter =
false>
60 atermpp::function_symbol f(function_name, number_of_arguments);
61 atermpp::function_symbol c(leaf_name, 0);
66 std::vector<atermpp::aterm> arguments(f.arity());
67 for (atermpp::aterm& argument: arguments)
71 atermpp::
aterm f_term(f, arguments.begin(), arguments.end());
73 for (std::size_t j = 0; j < depth; ++j)
76 for (atermpp::aterm& argument: arguments)
83 make_term_appl(f_term, f, arguments.begin(), arguments.end(), atermpp::detail::do_not_convert_term<atermpp::aterm>());
87 make_term_appl(f_term, f, arguments.begin(), arguments.end());
96template<std::size_t N>
100 atermpp::function_symbol f(function_name, N);
101 atermpp::function_symbol c(leaf_name, 0);
106 atermpp::
aterm f_term = [&]<std::size_t... I>(std::index_sequence<I...>)
108 return atermpp::aterm(f, (
static_cast<
void>(I), c_term)...);
109 }(std::make_index_sequence<N>{});
111 for (std::size_t j = 0; j < depth; ++j)
114 [&]<std::size_t... I>(std::index_sequence<I...>)
116 make_term_appl(f_term, f, (
static_cast<
void>(I), f_term)...);
117 }(std::make_index_sequence<N>{});
atermpp::aterm create_nested_function(const std::string &function_name, const std::string &leaf_name, std::size_t number_of_arguments, std::size_t depth)
Create a nested function application f_depth. Where f_0 = c and f_i = f(f_i-1,...,...
atermpp::aterm create_nested_function(const std::string &function_name, const std::string &leaf_name, std::size_t depth)
Create a nested function application f_depth. Where f_0 = c and f_i = f(f_i-1,...,...
void benchmark_threads(std::size_t number_of_threads, F f)
Run the given function f on number_of_threads threads (including the main thread) and report the elap...
void enable_garbage_collection(bool enable)
Enable garbage collection when passing true and disable otherwise.
A unordered_map class in which aterms can be stored.
Implements a simple stopwatch that starts on construction.
The main namespace for the aterm++ library.
int main(int argc, char *argv[])