Working on linux now, better logging
This commit is contained in:
@@ -1,7 +1,17 @@
|
||||
|
||||
#include "utils.h"
|
||||
#include <chrono>
|
||||
|
||||
typedef struct {
|
||||
std::chrono::time_point<std::chrono::system_clock> start;
|
||||
} timer;
|
||||
|
||||
|
||||
|
||||
static int _log_level = LOG_INFO;
|
||||
static timer *_timer = nullptr;
|
||||
|
||||
|
||||
|
||||
int logLevel()
|
||||
{
|
||||
@@ -23,3 +33,19 @@ const char *logIndicator(int l)
|
||||
}
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
void logElapsed()
|
||||
{
|
||||
if (_timer == nullptr) {
|
||||
_timer = new timer;
|
||||
_timer->start = std::chrono::system_clock::now();
|
||||
}
|
||||
|
||||
auto c = std::chrono::system_clock::now();
|
||||
auto duration = c - _timer->start;
|
||||
auto milliseconds
|
||||
= std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
duration)
|
||||
.count();
|
||||
fprintf(stderr, "%8.3lf: ", milliseconds/ 1000.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user