1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

Add GetPerfTimerStats (#451)

* Add getperfwarningtimeraverage query for validator-engine-console

* Fix for getperfwarningtimeraverage query

* getperftimerstats

* Add history max size: 1 hour

* PerfWarningTimer: move callback instead of copy

* PerfWarningTimer: fix move constructor bug

* PerfWarningTimer: fix bug: lifetime of the callback was greater than lifetime of the local variable 'manager' captured by reference

* Fix validate-query.cpp: 'manager' used after it was moved

* PerfWarningTimer: remove logs

* getperftimerstats: write to json file

* getperftimerstatsjson

Co-authored-by: legaii <jgates.ardux@gmail.com>
Co-authored-by: Ivan Siomash <106972486+legaii@users.noreply.github.com>
This commit is contained in:
EmelyanenkoK 2022-09-10 12:57:13 +03:00 committed by GitHub
parent 8376c289d7
commit 8329a58994
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 244 additions and 27 deletions

View file

@ -1005,3 +1005,53 @@ td::Status ImportShardOverlayCertificateQuery::receive(td::BufferSlice data) {
td::TerminalIO::out() << "successfully sent certificate to overlay manager\n";
return td::Status::OK();
}
td::Status GetPerfTimerStatsJsonQuery::run() {
TRY_RESULT_ASSIGN(file_name_, tokenizer_.get_token<std::string>());
TRY_STATUS(tokenizer_.check_endl());
return td::Status::OK();
}
td::Status GetPerfTimerStatsJsonQuery::send() {
auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_getPerfTimerStats>("");
td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise());
return td::Status::OK();
}
td::Status GetPerfTimerStatsJsonQuery::receive(td::BufferSlice data) {
TRY_RESULT_PREFIX(f, ton::fetch_tl_object<ton::ton_api::engine_validator_perfTimerStats>(data.as_slice(), true),
"received incorrect answer: ");
std::ofstream sb(file_name_);
sb << "{";
bool gtail = false;
for (const auto &v : f->stats_) {
if (gtail) {
sb << ",";
} else {
gtail = true;
}
sb << "\n '" << v->name_ << "': {";
bool tail = false;
for (const auto &stat : v->stats_) {
if (tail) {
sb << ",";
} else {
tail = true;
}
sb << "\n " << stat->time_ << ": [";
sb << "\n " << stat->min_ << ",";
sb << "\n " << stat->avg_ << ",";
sb << "\n " << stat->max_;
sb << "\n ]";
}
sb << "\n }";
}
sb << "\n}\n";
sb << std::flush;
td::TerminalIO::output(std::string("wrote stats to " + file_name_ + "\n"));
return td::Status::OK();
}