58 lines
1.2 KiB
C++
58 lines
1.2 KiB
C++
/**
|
|
* @file debugTimes.cpp
|
|
* @author Alexander Klein (alex@kleiax.de)
|
|
* @brief Implementation of the class debugTimes.h.
|
|
* @version 0.1
|
|
* @date 2021-12-13
|
|
*
|
|
* @copyright Copyright (c) 2021
|
|
*
|
|
*/
|
|
#include "debugTimes.h"
|
|
|
|
bool DebugTimes::print = false;
|
|
bool DebugTimes::printWarning = true;
|
|
|
|
DebugTimes::DebugTimes()
|
|
: startTime{millis()}
|
|
{
|
|
if (DebugTimes::printWarning)
|
|
{
|
|
std::cout << std::endl
|
|
<< "Warning: DebugTimes is muted, no times are be shown." << std::endl
|
|
<< std::endl;
|
|
DebugTimes::printWarning = false;
|
|
}
|
|
}
|
|
|
|
void DebugTimes::restart()
|
|
{
|
|
this->startTime = millis();
|
|
}
|
|
|
|
const uint16_t DebugTimes::stop()
|
|
{
|
|
return millis() - this->startTime;
|
|
}
|
|
|
|
const uint16_t DebugTimes::stopConsol(const char *name, uint16_t minTime)
|
|
{
|
|
const uint64_t time = millis() - this->startTime;
|
|
if (time > minTime && DebugTimes::print)
|
|
{
|
|
std::cout << name << " needs " << time << " ms" << std::endl;
|
|
}
|
|
return time;
|
|
}
|
|
|
|
void DebugTimes::setConsolOutput(bool enable)
|
|
{
|
|
if (enable == DebugTimes::print)
|
|
{
|
|
return;
|
|
}
|
|
|
|
DebugTimes::print = enable;
|
|
DebugTimes::printWarning = !enable;
|
|
}
|