2#include "barretenberg/env/logstr.hpp"
3#include "barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp"
9#define BENCHMARK_INFO_PREFIX "##BENCHMARK_INFO_PREFIX##"
10#define BENCHMARK_INFO_SEPARATOR "#"
11#define BENCHMARK_INFO_SUFFIX "##BENCHMARK_INFO_SUFFIX##"
13template <
typename... Args> std::string format(Args... args)
15 std::ostringstream os;
20template <
typename T>
void benchmark_format_chain(std::ostream& os, T
const& first)
23 std::stringstream current_argument;
24 current_argument << first;
25 std::string current_argument_string = current_argument.str();
26 std::replace(current_argument_string.begin(), current_argument_string.end(),
',',
';');
27 os << current_argument_string << BENCHMARK_INFO_SUFFIX;
30template <
typename T,
typename... Args>
31void benchmark_format_chain(std::ostream& os, T
const& first, Args
const&... args)
34 std::stringstream current_argument;
35 current_argument << first;
36 std::string current_argument_string = current_argument.str();
37 std::replace(current_argument_string.begin(), current_argument_string.end(),
',',
';');
38 os << current_argument_string << BENCHMARK_INFO_SEPARATOR;
39 benchmark_format_chain(os, args...);
42template <
typename... Args> std::string benchmark_format(Args... args)
44 std::ostringstream os;
45 os << BENCHMARK_INFO_PREFIX;
46 benchmark_format_chain(os, args...);
51template <
typename... Args>
inline void debug(Args... args)
53 logstr(format(args...).c_str());
56template <
typename... Args>
inline void debug(Args... ) {}
59template <
typename... Args>
inline void info(Args... args)
61 logstr(format(args...).c_str());
64template <
typename... Args>
inline void important(Args... args)
66 logstr(format(
"important: ", args...).c_str());
78template <
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4,
typename Arg5>
79inline void benchmark_info(Arg1 composer, Arg2 class_name, Arg3 operation, Arg4 metric, Arg5 value)
81 logstr(benchmark_format(composer, class_name, operation, metric, value).c_str());
84template <
typename... Args>
inline void benchmark_info(Args... ) {}
93 std::vector<std::string> saved_benchmarks;
112 template <
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4,
typename Arg5>
113 inline void benchmark_info_deferred(Arg1 composer, Arg2 class_name, Arg3 operation, Arg4 metric, Arg5 value)
115 saved_benchmarks.push_back(benchmark_format(composer, class_name, operation, metric, value).c_str());
119 : saved_benchmarks(std::move(saved_benchmarks))
121 template <
typename... Args>
inline void benchmark_info_deferred(Args... ) {}
125 for (
auto& x : saved_benchmarks) {
A class for saving benchmarks and printing them all at once in the end of the function.
Definition: log.hpp:91
BenchmarkInfoCollator(std::vector< std::string > saved_benchmarks)
Info used to store circuit statistics during CI/CD with concrete structure. Stores string in vector f...
Definition: log.hpp:118