7#include <unordered_map>
12#define AVM_TRACK_STATS
17#define AVM_TRACK_TIME(key, body) ::bb::avm2::Stats::get().time(key, [&]() { body; });
19#define AVM_TRACK_TIME_V(key, body) ::bb::avm2::Stats::get().time_r(key, [&]() { return body; });
21#define AVM_TRACK_TIME(key, body) body
22#define AVM_TRACK_TIME_V(key, body) body
32 void time(
const std::string&
key,
const std::function<
void()>& f);
34 template <
typename F>
auto time_r(
const std::string&
key,
F&& f)
36 auto start = std::chrono::system_clock::now();
38 auto elapsed = std::chrono::system_clock::now() - start;
40 static_cast<uint64_t>(std::chrono::duration_cast<std::chrono::milliseconds>(
elapsed).count()));
48 std::string
to_string(
int depth = 2)
const;
53 std::unordered_map<std::string, uint64_t>
stats;
void increment(const std::string &key, uint64_t value)
std::string to_string(int depth=2) const
auto time_r(const std::string &key, F &&f)
std::unordered_map< std::string, uint64_t > stats
void time(const std::string &key, const std::function< void()> &f)