From 9c65cdff83b661e04f42ba735c79418681e24dc3 Mon Sep 17 00:00:00 2001 From: Timon Habenicht <t.habenicht@tu-bs.de> Date: Fri, 23 Nov 2018 11:03:20 +0100 Subject: [PATCH] adds miliseconds to Test Time --- .../Utilities/TestSimulation/TestSimulation.h | 4 ---- .../Utilities/TestSimulation/TestSimulationImp.cpp | 11 +++++++---- .../Utilities/TestSimulation/TestSimulationImp.h | 8 ++++---- targets/tests/NumericalTests/main.cpp | 5 ----- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulation.h b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulation.h index ffbf2d909..01fb73e0f 100644 --- a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulation.h +++ b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulation.h @@ -26,10 +26,6 @@ public: virtual void makeSimulationHeadOutput() = 0; virtual void setSimulationStartTime() = 0; virtual void setSimulationEndTimeAndNotifyObserver() = 0; - - virtual void setTestStartTime() = 0; - virtual void setTestEndTime() = 0; - private: }; diff --git a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp index 2fa45ed11..371065a43 100644 --- a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp +++ b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp @@ -54,9 +54,10 @@ double TestSimulationImp::calcSimTime() return difftime(simulationEndTime, simulationStartTime); } -double TestSimulationImp::calcTestTime() +float TestSimulationImp::calcTestTime() { - return difftime(testEndTime, testStartTime); + float timeInMiliSec = ((float)(testEndTime - testStartTime) / CLOCKS_PER_SEC); + return timeInMiliSec; } void TestSimulationImp::makeSimulationHeadOutput() @@ -73,17 +74,19 @@ void TestSimulationImp::setSimulationEndTimeAndNotifyObserver() { simulationEndTime = time(NULL); simualtionRun = true; + setTestStartTime(); notifyObserver(); + setTestEndTime(); } void TestSimulationImp::setTestStartTime() { - testStartTime = time(NULL); + testStartTime = clock(); } void TestSimulationImp::setTestEndTime() { - testEndTime = time(NULL); + testEndTime = clock(); } std::string TestSimulationImp::getRunTimeOutput() diff --git a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h index 5a63d60a4..4b06b1700 100644 --- a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h +++ b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h @@ -25,15 +25,15 @@ public: void makeSimulationHeadOutput(); void setSimulationStartTime(); void setSimulationEndTimeAndNotifyObserver(); - void setTestStartTime(); - void setTestEndTime(); std::string getRunTimeOutput(); private: TestSimulationImp(int simID, std::shared_ptr< SimulationParameter> simPara, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< ColorConsoleOutput> colorOutput); void notifyObserver(); + void setTestStartTime(); + void setTestEndTime(); double calcSimTime(); - double calcTestTime(); + float calcTestTime(); std::shared_ptr< SimulationParameter> simPara; std::shared_ptr< SimulationInfo> simInfo; @@ -44,7 +44,7 @@ private: bool simualtionRun; time_t simulationStartTime, simulationEndTime; - time_t testStartTime, testEndTime; + clock_t testStartTime, testEndTime; int simID; }; #endif \ No newline at end of file diff --git a/targets/tests/NumericalTests/main.cpp b/targets/tests/NumericalTests/main.cpp index 77ef04a17..8c0697cab 100644 --- a/targets/tests/NumericalTests/main.cpp +++ b/targets/tests/NumericalTests/main.cpp @@ -5,7 +5,6 @@ #include "Utilities\LogFileQueue\LogFileQueue.h" #include "Utilities\NumericalTestFactory\NumericalTestFactoryImp.h" #include "Utilities\TestQueue\TestQueue.h" -#include "Utilities\TestSimulation\TestSimulation.h" #include "Utilities\VirtualFluidSimulation\VirtualFluidSimulation.h" #include "Utilities\VirtualFluidSimulationFactory\VirtualFluidSimulationFactoryImp.h" @@ -24,12 +23,8 @@ static void startNumericalTests(const std::string &configFile) for (int i = 0; i < vfSimulations.size(); i++) { - if (i > 0) - testSim.at(i)->setTestEndTime(); vfSimulations.at(i)->run(); - testSim.at(i)->setTestStartTime(); } - testSim.at(testSim.size()-1)->setTestEndTime(); testQueue->makeFinalOutput(); logFileQueue->writeLogFiles(); -- GitLab