Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F88693213
surface_timer.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Oct 20, 05:09
Size
2 KB
Mime Type
text/x-c
Expires
Tue, Oct 22, 05:09 (2 d)
Engine
blob
Format
Raw Data
Handle
21498453
Attached To
rTAMAAS tamaas
surface_timer.hh
View Options
/**
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 2016 EPFL (Ecole Polytechnique Fédérale de
* Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
* Solides)
*
* Tamaas is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Tamaas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Tamaas. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#ifndef TIMER_HH
#define TIMER_HH
__BEGIN_TAMAAS__
#if defined(TIMER) && defined(USING_TIMER)
/* -------------------------------------------------------------------------- */
#include <map>
#include <time.h>
#include <fstream>
/* -------------------------------------------------------------------------- */
extern
std
::
map
<
std
::
string
,
struct
timespec
>
mesT
;
extern
std
::
map
<
std
::
string
,
UInt
>
nmes
;
extern
std
::
map
<
std
::
string
,
struct
timespec
>
tstart
;
extern
std
::
map
<
std
::
string
,
struct
timespec
>
tstop
;
/* -------------------------------------------------------------------------- */
#define SEC_IN_NANOSEC 1000000000
/* -------------------------------------------------------------------------- */
#define STARTTIMER(x) { \
if (!mesT.count(x)) { \
mesT[x].tv_sec = 0; \
mesT[x].tv_nsec = 0; \
} \
clock_gettime(CLOCK_REALTIME,&(tstart[x])); \
}
/* -------------------------------------------------------------------------- */
#define STOPTIMER(x) { \
clock_gettime(CLOCK_REALTIME,&(tstop[x])); \
mesT[x].tv_sec += (tstop[x].tv_sec - tstart[x].tv_sec); \
mesT[x].tv_nsec += (tstop[x].tv_nsec - tstart[x].tv_nsec); \
if (mesT[x].tv_nsec < 0) { \
--mesT[x].tv_sec; \
mesT[x].tv_nsec += SEC_IN_NANOSEC; \
} \
if (mesT[x].tv_nsec >= SEC_IN_NANOSEC){ \
++mesT[x].tv_sec; \
mesT[x].tv_nsec -= SEC_IN_NANOSEC; \
} \
++nmes[x]; \
}
/* -------------------------------------------------------------------------- */
#else
#define STARTTIMER(x)
#define STOPTIMER(x)
#endif
void
dumpTimes
(
UInt
proc_number
=
0
);
__END_TAMAAS__
#endif
// TIMER_HH
Event Timeline
Log In to Comment