It's starting to become a proper challange

This commit is contained in:
2019-06-26 14:44:06 +02:00
parent da749e84f4
commit 0c9768e065
8 changed files with 500265 additions and 46 deletions

View File

@@ -1,5 +1,10 @@
#include "profiler.hpp"
#include <iostream>
#include <sstream>
#include <iomanip>
using namespace std;
using std::string;
Profiler profiler;
@@ -9,8 +14,27 @@ void Profiler::record_function_call(const char *function_name)
calls[function_name]++;
}
void Profiler::clear()
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;
}