some more bugfixes

This commit is contained in:
Robin Müller 2020-04-08 19:30:39 +02:00
parent 5b0f80509f
commit 640cc1ddec
2 changed files with 5 additions and 6 deletions

View File

@ -9,7 +9,7 @@
#include <iomanip>
Stopwatch::Stopwatch(bool displayOnDestruction,
StopwatchDisplayMode displayMode):
StopwatchDisplayMode displayMode): displayMode(displayMode),
displayOnDestruction(displayOnDestruction) {
// Measures start time on initialization.
Clock::getUptime(&startTime);
@ -32,12 +32,12 @@ seconds_t Stopwatch::stopSeconds() {
void Stopwatch::display() {
if(displayMode == StopwatchDisplayMode::MILLIS) {
info << "Stopwatch: Operation took " << elapsedTime.tv_sec * 1000 +
elapsedTime.tv_usec * 1000 << " milliseconds";
elapsedTime.tv_usec * 1000 << " milliseconds" << std::endl;
}
else if(displayMode == StopwatchDisplayMode::SECONDS) {
info <<"Stopwatch: Operation took " << std::setprecision(4)
info <<"Stopwatch: Operation took " << std::setprecision(3)
<< std::fixed << timevalOperations::toDouble(elapsedTime)
<< " seconds";
<< " seconds" << std::endl;
}
}

View File

@ -60,9 +60,8 @@ private:
timeval startTime {0, 0};
timeval elapsedTime {0, 0};
bool displayOnDestruction = true;
StopwatchDisplayMode displayMode = StopwatchDisplayMode::MILLIS;
bool displayOnDestruction = true;
void stopInternal();
};