1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-02-12 11:12:16 +00:00
ton/tdactor/td/actor/ActorStats.h
birydrad 72020c04c4
celldb in-memory mode, stats for actors, perf counters, minor fix in rldp2 (#1164)
* getactorstats query for validator-engine-console

* celldb in-memory mode (--celldb-in-memory option)

* rldp2: bugfix - do not estimate speed while nothing is sent

* add simple ed25519 benchmark

* fix compilation errors of different platforms and move to c++20

* fix some warnings

* turn on TON_USE_ABSEIL for glibc 2.27 nix build

---------

Co-authored-by: birydrad <>
2024-09-23 17:34:37 +03:00

52 lines
1.3 KiB
C++

#pragma once
#include "td/actor/actor.h"
#include "td/utils/TimedStat.h"
namespace td {
namespace actor {
class ActorStats : public td::actor::Actor {
public:
ActorStats() {
}
void start_up() override;
double estimate_inv_ticks_per_second();
std::string prepare_stats();
private:
template <class T>
struct StatStorer {
void on_event(const T &event) {
if (!first_) {
first_ = event;
first_ts_ = Clocks::rdtsc();
}
}
double get_duration(double inv_ticks_per_second) const {
if (first_) {
return std::max(1.0, (Clocks::rdtsc() - first_ts_) * inv_ticks_per_second);
}
return 1.0;
}
td::optional<T> first_;
td::uint64 first_ts_;
};
static constexpr std::size_t SIZE = 2;
static constexpr const char *DESCR[SIZE] = {"10sec", "10min"};
static constexpr int DURATIONS[SIZE] = {10, 10 * 60};
td::TimedStat<StatStorer<td::actor::ActorTypeStats>> stat_[SIZE];
struct PefStat {
PefStat();
td::TimedStat<StatStorer<td::int64>> perf_stat_[SIZE];
};
std::map<std::string, PefStat> pef_stats_;
td::Timestamp begin_ts_;
td::uint64 begin_ticks_{};
void loop() override {
alarm_timestamp() = td::Timestamp::in(5.0);
update(td::Timestamp::now());
}
void update(td::Timestamp now);
};
} // namespace actor
} // namespace td