added stopwatch printf support
This commit is contained in:
parent
583d354fb5
commit
7b82a7c1a7
@ -1,5 +1,5 @@
|
|||||||
#include "Stopwatch.h"
|
#include "Stopwatch.h"
|
||||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
#include "../serviceinterface/ServiceInterface.h"
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
Stopwatch::Stopwatch(bool displayOnDestruction,
|
Stopwatch::Stopwatch(bool displayOnDestruction,
|
||||||
@ -28,9 +28,13 @@ double Stopwatch::stopSeconds() {
|
|||||||
|
|
||||||
void Stopwatch::display() {
|
void Stopwatch::display() {
|
||||||
if(displayMode == StopwatchDisplayMode::MILLIS) {
|
if(displayMode == StopwatchDisplayMode::MILLIS) {
|
||||||
|
dur_millis_t timeMillis = static_cast<dur_millis_t>(
|
||||||
|
elapsedTime.tv_sec * 1000 + elapsedTime.tv_usec / 1000);
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::info << "Stopwatch: Operation took " << (elapsedTime.tv_sec * 1000 +
|
sif::info << "Stopwatch: Operation took " << timeMillis << " milliseconds" << std::endl;
|
||||||
elapsedTime.tv_usec / 1000) << " milliseconds" << std::endl;
|
#else
|
||||||
|
sif::printInfo("Stopwatch: Operation took %lu milliseconds\n\r",
|
||||||
|
static_cast<unsigned int>(timeMillis));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if(displayMode == StopwatchDisplayMode::SECONDS) {
|
else if(displayMode == StopwatchDisplayMode::SECONDS) {
|
||||||
@ -38,6 +42,9 @@ void Stopwatch::display() {
|
|||||||
sif::info <<"Stopwatch: Operation took " << std::setprecision(3)
|
sif::info <<"Stopwatch: Operation took " << std::setprecision(3)
|
||||||
<< std::fixed << timevalOperations::toDouble(elapsedTime)
|
<< std::fixed << timevalOperations::toDouble(elapsedTime)
|
||||||
<< " seconds" << std::endl;
|
<< " seconds" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("Stopwatch: Operation took %.3f seconds\n\r",
|
||||||
|
static_cast<float>(timevalOperations::toDouble(elapsedTime)));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user