add a timer to the propagator to record propagation time in runUntilTerminate()
This commit is contained in:
parent
0734d6a013
commit
48d1a933ab
@ -3,10 +3,12 @@
|
|||||||
|
|
||||||
#include "sim/RK4Solver.h"
|
#include "sim/RK4Solver.h"
|
||||||
#include "model/Rocket.h"
|
#include "model/Rocket.h"
|
||||||
|
#include "utils/Logger.h"
|
||||||
#include "QtRocket.h"
|
#include "QtRocket.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <QTextStream>
|
#include <chrono>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
namespace sim {
|
namespace sim {
|
||||||
|
|
||||||
@ -45,8 +47,9 @@ Propagator::~Propagator()
|
|||||||
|
|
||||||
void Propagator::runUntilTerminate()
|
void Propagator::runUntilTerminate()
|
||||||
{
|
{
|
||||||
|
std::chrono::steady_clock::time_point startTime = std::chrono::steady_clock::now();
|
||||||
|
std::chrono::steady_clock::time_point endTime;
|
||||||
|
|
||||||
QTextStream out(stdout);
|
|
||||||
std::size_t j = 0;
|
std::size_t j = 0;
|
||||||
while(true && j < 100000)
|
while(true && j < 100000)
|
||||||
{
|
{
|
||||||
@ -66,19 +69,19 @@ void Propagator::runUntilTerminate()
|
|||||||
{
|
{
|
||||||
states.push_back(currentState);
|
states.push_back(currentState);
|
||||||
}
|
}
|
||||||
out << currentTime << ": ("
|
|
||||||
<< currentState[0] << ", "
|
|
||||||
<< currentState[1] << ", "
|
|
||||||
<< currentState[2] << ", "
|
|
||||||
<< currentState[3] << ", "
|
|
||||||
<< currentState[4] << ", "
|
|
||||||
<< currentState[5] << ")\n";
|
|
||||||
if(currentState[2] < 0.0)
|
if(currentState[2] < 0.0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
j++;
|
j++;
|
||||||
currentTime += timeStep;
|
currentTime += timeStep;
|
||||||
}
|
}
|
||||||
|
endTime = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
|
std::stringstream duration;
|
||||||
|
duration << "runUntilTerminate time (microseconds): ";
|
||||||
|
duration << std::chrono::duration_cast<std::chrono::microseconds>(endTime - startTime).count();
|
||||||
|
utils::Logger::getInstance()->debug(duration.str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double Propagator::getMass()
|
double Propagator::getMass()
|
||||||
|
@ -18,12 +18,6 @@ Logger* Logger::getInstance()
|
|||||||
Logger::Logger()
|
Logger::Logger()
|
||||||
{
|
{
|
||||||
outFile.open("log.txt");
|
outFile.open("log.txt");
|
||||||
/*
|
|
||||||
error = [this](std::string_view msg) { log(msg, ERROR); };
|
|
||||||
warn = [this](std::string_view msg) { log(msg, WARN); };
|
|
||||||
info = [this](std::string_view msg) { log(msg, INFO); };
|
|
||||||
debug = [this](std::string_view msg) { log(msg, DEBUG); };
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::~Logger()
|
Logger::~Logger()
|
||||||
@ -42,21 +36,21 @@ void Logger::log(std::string_view msg, const LogLevel& lvl)
|
|||||||
if(lvl == DEBUG)
|
if(lvl == DEBUG)
|
||||||
{
|
{
|
||||||
outFile << "[DEBUG] " << msg << std::endl;
|
outFile << "[DEBUG] " << msg << std::endl;
|
||||||
std::cout << "[DEBUG] " << msg << std::endl;
|
std::cout << "[DEBUG] " << msg << "\n";
|
||||||
}
|
}
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case INFO:
|
case INFO:
|
||||||
if(lvl == INFO)
|
if(lvl == INFO)
|
||||||
{
|
{
|
||||||
outFile << "[INFO] " << msg << std::endl;
|
outFile << "[INFO] " << msg << std::endl;
|
||||||
std::cout << "[INFO] " << msg << std::endl;
|
std::cout << "[INFO] " << msg << "\n";
|
||||||
}
|
}
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case WARN:
|
case WARN:
|
||||||
if(lvl == WARN)
|
if(lvl == WARN)
|
||||||
{
|
{
|
||||||
outFile << "[WARN] " << msg << std::endl;
|
outFile << "[WARN] " << msg << std::endl;
|
||||||
std::cout << "[WARN] " << msg << std::endl;
|
std::cout << "[WARN] " << msg << "\n";
|
||||||
}
|
}
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
// Regardless of what level is set, ERROR is always logged, so
|
// Regardless of what level is set, ERROR is always logged, so
|
||||||
@ -65,8 +59,7 @@ void Logger::log(std::string_view msg, const LogLevel& lvl)
|
|||||||
if(lvl == ERROR)
|
if(lvl == ERROR)
|
||||||
{
|
{
|
||||||
outFile << "[ERROR] " << msg << std::endl;
|
outFile << "[ERROR] " << msg << std::endl;
|
||||||
std::cout << "[ERROR] " << msg << std::endl;
|
std::cout << "[ERROR] " << msg << "\n";
|
||||||
std::cerr << "[ERROR] " << msg << std::endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
//#include <functional>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo write docs
|
* @todo write docs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user