basic version of profiler class

This commit is contained in:
2021-03-22 06:50:15 +01:00
parent a931661608
commit 56407f3516
4 changed files with 94 additions and 11 deletions

28
ml_profiler.h Normal file
View File

@@ -0,0 +1,28 @@
#pragma once
#include "ml.h"
#include <unordered_map>
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;
};