Skip to content

Commit 2ce550f

Browse files
VsevolodVsevolod
authored andcommitted
added time measurement for fortran procedure
1 parent 41bc639 commit 2ce550f

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

fortran_modules.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef FORTRAN_MODULES_H
22
#define FORTRAN_MODULES_H
33

4+
#include "time_utils.h"
5+
46
// the next funxtions are defined in Kul.f90 and linked from fortran_modules/Kul.o
57
extern "C" int laplace_(int*,Point*,Point*,Point*); // integer function Laplace(N,P1,P2,P3)
68
extern "C" void resultf_(Point*,real*,Vector*); //ResultF(Point, Pot, Grad)
@@ -20,8 +22,16 @@ int solveBoundaryProblem(vector<PlaneType> *coordinatesList,bool verbose = false
2022
}
2123

2224
// Solve boundary-valued problem
25+
timespec start, stop, *delta;
2326
verbose && COUT("solving boundary problem in fortran module...");
27+
clock_gettime(CLOCK_ID,&start);
2428
int retval = laplace_(&numVertices,P1,P2,P3);
29+
clock_gettime(CLOCK_ID,&stop);
30+
delta = Time::getTimespecDelta(&start,&stop);
31+
if (verbose) {
32+
PRINT("elapsed time: ");
33+
Time::printTimespec(delta);
34+
}
2535
delete[] P1,P2,P3;
2636

2737
verbose && COUT("fortran init retval: " << retval);

fortran_modules/gf

100644100755
File mode changed.

time_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
int CLOCK_ID = CLOCK_THREAD_CPUTIME_ID;
44

55
void Time::printTimespec(timespec *ts) {
6-
cout << "seconds: " << ts->tv_sec << ", nanoseconds: " << ts->tv_nsec << endl;
6+
cout << ts->tv_sec << '.' << std::setfill('0') << std::setw(9) << ts->tv_nsec << " sec" << endl;
77
}
88

99
timespec* Time::getTimespecDelta(timespec *older,timespec *newer) {

time_utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <iostream>
88
#include <random>
99
#include <functional>
10+
#include <iomanip>
1011
#include "constants.h"
1112

1213
using namespace std;

0 commit comments

Comments
 (0)