mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
refactor: Improve utils code style (#841)
* Improve utils code style * Fix indendation Co-authored-by: brindosch <edeltraud70@gmx.de>
This commit is contained in:
@@ -18,7 +18,7 @@ Logger* Profiler::_logger = nullptr;
|
||||
|
||||
double getClockDelta(clock_t start)
|
||||
{
|
||||
return ((double)(clock() - start) / CLOCKS_PER_SEC) ;
|
||||
return ((double)(clock() - start) / CLOCKS_PER_SEC);
|
||||
}
|
||||
|
||||
Profiler::Profiler(const char* sourceFile, const char* func, unsigned int line)
|
||||
@@ -35,12 +35,12 @@ Profiler::Profiler(const char* sourceFile, const char* func, unsigned int line)
|
||||
|
||||
Profiler::~Profiler()
|
||||
{
|
||||
_logger->Message( Logger::DEBUG, _file,_func, _line, "<<< exit block %d, executed for %f s", _blockId, getClockDelta(_startTime) );
|
||||
_logger->Message( Logger::DEBUG, _file,_func, _line, "<<< exit block %d, executed for %f s", _blockId, getClockDelta(_startTime));
|
||||
}
|
||||
|
||||
void Profiler::initLogger()
|
||||
{
|
||||
if (_logger == nullptr )
|
||||
if (_logger == nullptr)
|
||||
_logger = Logger::getInstance("PROFILER", Logger::DEBUG);
|
||||
}
|
||||
|
||||
@@ -52,22 +52,22 @@ void Profiler::TimerStart(const QString timerName, const char* sourceFile, const
|
||||
StopWatchItem item = {sourceFile, func, line};
|
||||
|
||||
ret = GlobalProfilerMap.emplace(timerName, item);
|
||||
if ( ! ret.second )
|
||||
if (!ret.second)
|
||||
{
|
||||
if ( ret.first->second.sourceFile == sourceFile && ret.first->second.func == func && ret.first->second.line == line )
|
||||
if (ret.first->second.sourceFile == sourceFile && ret.first->second.func == func && ret.first->second.line == line)
|
||||
{
|
||||
_logger->Message(Logger::DEBUG, sourceFile, func, line, "restart timer '%s'", QSTRING_CSTR(timerName) );
|
||||
_logger->Message(Logger::DEBUG, sourceFile, func, line, "restart timer '%s'", QSTRING_CSTR(timerName));
|
||||
ret.first->second.startTime = clock();
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger->Message(Logger::DEBUG, sourceFile, func, line, "ERROR timer '%s' started in multiple locations. First occurence %s:%d:%s()",
|
||||
QSTRING_CSTR(timerName), FileUtils::getBaseName(ret.first->second.sourceFile).toLocal8Bit().constData(), ret.first->second.line, ret.first->second.func );
|
||||
QSTRING_CSTR(timerName), FileUtils::getBaseName(ret.first->second.sourceFile).toLocal8Bit().constData(), ret.first->second.line, ret.first->second.func);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger->Message(Logger::DEBUG, sourceFile, func, line, "start timer '%s'", QSTRING_CSTR(timerName) );
|
||||
_logger->Message(Logger::DEBUG, sourceFile, func, line, "start timer '%s'", QSTRING_CSTR(timerName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,11 +79,11 @@ void Profiler::TimerGetTime(const QString timerName, const char* sourceFile, con
|
||||
if (ret != GlobalProfilerMap.end())
|
||||
{
|
||||
_logger->Message(Logger::DEBUG, sourceFile, func, line, "timer '%s' started at %s:%d:%s() took %f s execution time until here", QSTRING_CSTR(timerName),
|
||||
FileUtils::getBaseName(ret->second.sourceFile).toLocal8Bit().constData(), ret->second.line, ret->second.func, getClockDelta(ret->second.startTime) );
|
||||
FileUtils::getBaseName(ret->second.sourceFile).toLocal8Bit().constData(), ret->second.line, ret->second.func, getClockDelta(ret->second.startTime));
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger->Message(Logger::DEBUG, sourceFile, func, line, "ERROR timer '%s' not started", QSTRING_CSTR(timerName) );
|
||||
_logger->Message(Logger::DEBUG, sourceFile, func, line, "ERROR timer '%s' not started", QSTRING_CSTR(timerName));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user