callstack added

This commit is contained in:
2021-04-09 00:07:20 +02:00
parent 5afa7dd69f
commit 9ab0a2c98d
5 changed files with 72 additions and 27 deletions

View File

@@ -3,10 +3,12 @@
#include "ml.h"
#include <unordered_map>
#include <deque>
#include <chrono>
static const int method_name_print_len = 15;
static const int print_top_methods = 15;
static const int call_stack_max_methods = 10;
class MlPerfMon {
@@ -24,10 +26,13 @@ public:
void turnOn();
void add_method_call(const std::string &method);
void end_method_call();
std::string callstack() const;
void print_results();
private:
bool perfOn;
std::unordered_map<std::string, long> calls_counter;
std::chrono::time_point<std::chrono::high_resolution_clock> start_time;
std::deque<std::string> call_stack;
};