Files
open_pit/profiler.cpp

41 lines
675 B
C++

#include "profiler.hpp"
#include <iostream>
#include <sstream>
#include <iomanip>
using namespace std;
using std::string;
Profiler profiler;
void Profiler::record_function_call(const char *function_name)
{
calls[function_name]++;
}
void Profiler::reset()
{
calls.clear();
}
bool Profiler::command_line(const string &input)
{
if (input == "profiler_print")
{
for (auto it = this->calls.begin();it != this->calls.end();it++)
{
ostringstream out;
out << left << setw(25) << it->first << right << setw(5) << it->second;
cout << out.str() << endl;
}
return true;
}
if (input == "profiler_reset")
{
this->reset();
return true;
}
return false;
}