DistDir
timer.h
Go to the documentation of this file.
1 /*
2  * @file timer.h
3  *
4  * @copyright Copyright (C) 2024 Enrico Degregori <enrico.degregori@gmail.com>
5  *
6  * @author Enrico Degregori <enrico.degregori@gmail.com>
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10 
11  * 1. Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13 
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17 
18  * 3. Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef TIMER_H
35 #define TIMER_H
36 
37 #include "mpi.h"
38 
39 #define STRING_MAX 1024
40 
46 struct t_timer_data {
47 
49  int id;
51  char* name;
53  double total_time;
55  double start_time;
56 };
57 typedef struct t_timer_data t_timer_data;
58 
65 {
66 
70  struct t_list_node *next;
71 };
72 typedef struct t_list_node t_list_node;
73 
87 int new_timer(const char * timer_name) ;
88 
98 void timer_start(int timer_id) ;
99 
111 void timer_stop(int timer_id) ;
112 
124 
132 void timers_reset() ;
133 
143 
144 #endif
void timers_report()
Create reports of all timers.
void delete_timers()
Free timers memory.
void timer_start(int timer_id)
Start timer based on ID.
void timer_stop(int timer_id)
Stop timer based on ID.
int new_timer(const char *timer_name)
Create a new timer.
void timers_reset()
Reset all the timers.
The structure contains a linked list single node for the timer module.
Definition: timer.h:65
struct t_list_node * next
pointer to next node of the linked list
Definition: timer.h:70
t_timer_data * data
pointer to t_timer_data holding single timer information
Definition: timer.h:68
The structure contains information about a single timer.
Definition: timer.h:46
double total_time
timer total time
Definition: timer.h:53
char * name
timer name
Definition: timer.h:51
double start_time
timer start time
Definition: timer.h:55
int id
timer ID
Definition: timer.h:49