PaStiX Handbook 6.4.0
Loading...
Searching...
No Matches
simu_timer.h
Go to the documentation of this file.
1/**
2 *
3 * @file simu_timer.h
4 *
5 * PaStiX simulation timer.
6 *
7 * @copyright 2004-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8 * Univ. Bordeaux. All rights reserved.
9 *
10 * @version 6.4.0
11 * @author Pascal Henon
12 * @author Mathieu Faverge
13 * @date 2024-07-05
14 *
15 * @addtogroup blend_dev_simu
16 * @{
17 *
18 **/
19#ifndef _simu_timer_h_
20#define _simu_timer_h_
21
22/**
23 * @brief Timer for the simulation.
24 */
25typedef struct simu_timer_s {
26 double s; /**< Second in the timer */
27 /* double ms;*/
29
30/**
31 * @brief Compare two timings
32 * @param[in] t1
33 * The first timer.
34 * @param[in] t2
35 * The second timer.
36 * @return True if the t1 is smaller than t2, false otherwise.
37 */
38static inline int
40 const SimuTimer *t2)
41{
42 /* Return (t1 < t2) */
43 if(t1->s < t2->s) {
44 return 1;
45 }
46 else {
47 return 0;
48 }
49}
50
51/**
52 * @brief Increment the timer
53 * @param[inout] timer
54 * The timer to update.
55 * @param[in] t
56 * The time to add to the timer.
57 */
58static inline void
59timerAdd(SimuTimer *timer, double t)
60{
61 timer->s += t;
62}
63
64/**
65 * @brief Get the timer value
66 * @param[in] timer
67 * The timer to read.
68 * @return The timer value in second.
69 */
70static inline double
71timerVal(const SimuTimer *timer)
72{
73 return timer->s;
74}
75
76/**
77 * @brief Set the timer value
78 * @param[inout] timer
79 * The timer to set
80 * @param[in] t
81 * The value to set
82 */
83static inline void
84timerSet(SimuTimer *timer, double t)
85{
86 timer->s = t;
87}
88
89/**
90 * @brief Set the timer value if the value is greater than the actual one.
91 * @param[inout] timer
92 * The timer to update
93 * @param[in] t
94 * The time to compare with and set if larger than the timer.
95 */
96static inline void
97timerSetMax(SimuTimer *timer, double t)
98{
99 if ( t > timer->s ) {
100 timer->s = t;
101 }
102}
103
104#endif /* _simu_timer_h_ */
105
106/**
107 *@}
108 */
static void timerSetMax(SimuTimer *timer, double t)
Set the timer value if the value is greater than the actual one.
Definition simu_timer.h:97
static double timerVal(const SimuTimer *timer)
Get the timer value.
Definition simu_timer.h:71
static void timerAdd(SimuTimer *timer, double t)
Increment the timer.
Definition simu_timer.h:59
struct simu_timer_s SimuTimer
Timer for the simulation.
static int timerComp(const SimuTimer *t1, const SimuTimer *t2)
Compare two timings.
Definition simu_timer.h:39
static void timerSet(SimuTimer *timer, double t)
Set the timer value.
Definition simu_timer.h:84
Timer for the simulation.
Definition simu_timer.h:25