Files
Bachelorarbeit-Rover/lib/Times/debugTimes.cpp
T
2022-10-24 22:08:19 +02:00

38 lines
932 B
C++

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