Skip to content

Commit d9ca68f

Browse files
committed
Add C++ timer for mesh reading and time integration
1 parent 2910f54 commit d9ca68f

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

srcs/main.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <chrono>
12
#include <iostream>
23
#include <string>
34
#if defined(_OPENMP)
@@ -47,14 +48,22 @@ int main(int argc, char **argv)
4748
<< std::endl
4849
<< "================================================================"
4950
<< std::endl;
51+
5052
Mesh mesh;
53+
auto startTime = std::chrono::high_resolution_clock::now();
5154
if(!readMesh(mesh, std::string(argv[1]), solverParams.spaceIntType,
5255
solverParams.basisFuncType))
5356
{
5457
std::cerr << "Something went wrong when reading mesh file: "
5558
<< argv[1] << std::endl;
5659
return -1;
57-
}
60+
}
61+
auto endTime = std::chrono::high_resolution_clock::now();
62+
auto ellapsedTime = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
63+
64+
std::cout << "Ellapsed time for mesh reading: "
65+
<< static_cast<double>(ellapsedTime.count())/1000.0
66+
<< " s" << std::endl;
5867

5968
// displayMesh(mesh);
6069
std::cout << "================================================================"
@@ -63,11 +72,19 @@ int main(int argc, char **argv)
6372
<< std::endl
6473
<< "================================================================"
6574
<< std::endl;
75+
76+
startTime = std::chrono::high_resolution_clock::now();
6677
if(!timeInteg(mesh, solverParams, std::string(argv[1])))
6778
{
6879
std::cerr << "Something went wrong when time integrating" << std::endl;
6980
return -1;
7081
}
82+
endTime = std::chrono::high_resolution_clock::now();
83+
ellapsedTime = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
84+
85+
std::cout << "Ellapsed time for time integration: "
86+
<< static_cast<double>(ellapsedTime.count())/1000.0
87+
<< " s" << std::endl;
7188

7289
return 0;
7390
}

srcs/solver/timeInteg.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ bool timeInteg(const Mesh& mesh, const SolverParams& solverParams,
213213
for(unsigned int nbrStep = 1 ; nbrStep < nTimeSteps + 1 ;
214214
nbrStep++)
215215
{
216-
217216
// display progress
218217
ratio = int(100*double(nbrStep - 1)/double(nTimeSteps));
219218
if(ratio >= currentDecade)
@@ -223,10 +222,8 @@ bool timeInteg(const Mesh& mesh, const SolverParams& solverParams,
223222
currentDecade = ratio + 1;
224223
}
225224

226-
227225
integScheme(t, field, partialField, matrix, mesh, solverParams, temp, usedF);
228226

229-
230227
// check that it does not diverge
231228
// assert(field.u[0].maxCoeff() <= 1E5);
232229

0 commit comments

Comments
 (0)