34 lines
681 B
C++
34 lines
681 B
C++
#pragma once
|
|
|
|
#include "ml.h"
|
|
|
|
#include <unordered_map>
|
|
#include <chrono>
|
|
|
|
static const int method_name_print_len = 15;
|
|
static const int print_top_methods = 15;
|
|
|
|
class MlPerfMon {
|
|
|
|
private:
|
|
MlPerfMon() : perfOn(false) {};
|
|
|
|
public:
|
|
|
|
// https://stackoverflow.com/questions/43523509/simple-singleton-example-in-c
|
|
static MlPerfMon& instance(){
|
|
static MlPerfMon instance;
|
|
return instance;
|
|
}
|
|
|
|
void turnOn();
|
|
|
|
void add_method_call(const std::string &method);
|
|
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;
|
|
};
|