Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
uniformize gras_os_sleep prototype (seconds are double everywhere else, avoid roundin...
[simgrid.git] / include / gras / chrono.h
1 /*      $Id$     */
2
3 /* chrono.h - timer macros for GRAS                                         */
4
5 /* Copyright (c) 2005 Martin Quinson, Arnaud Legrand. All rights reserved.  */
6
7 /* This program is free software; you can redistribute it and/or modify it
8  * under the terms of the license (GNU LGPL) which comes with this package. */
9
10
11 #ifndef GRAS_CHRONO_H
12 #define GRAS_CHRONO_H
13
14 #include "xbt/misc.h"
15 #include "gras/cond.h"
16
17 BEGIN_DECL()
18
19 void gras_chrono_init(void);
20 int gras_bench_always_begin(const char *location, int line);
21 int gras_bench_always_end(void);
22 int gras_bench_once_begin(const char *location, int line);
23 int gras_bench_once_end(void);
24
25 /** \brief Start benchmark this part of the code
26     \hideinitializer */
27 #define GRAS_BENCH_ALWAYS_BEGIN()  do { if(gras_if_SG()) gras_bench_always_begin(__FILE__, __LINE__); } while(0)
28 /** \brief Stop benchmark this part of the code
29     \hideinitializer */
30 #define GRAS_BENCH_ALWAYS_END() do { if(gras_if_SG()) gras_bench_always_end(); } while(0)
31
32 /** \brief Start benchmark this part of the code if it has never been benchmarked before
33     \hideinitializer */
34 #define GRAS_BENCH_ONCE_RUN_ALWAYS_BEGIN()  do { if(gras_if_SG()) gras_bench_once_begin(__FILE__, __LINE__); } while(0)
35 /** \brief Stop benchmarking this part of the code
36     \hideinitializer */
37 #define GRAS_BENCH_ONCE_RUN_ALWAYS_END()    do { if(gras_if_SG()) gras_bench_once_end(); } while(0)
38
39 /** \brief Start benchmark this part of the code if it has never been benchmarked before
40     \hideinitializer */
41 #define GRAS_BENCH_ONCE_RUN_ONCE_BEGIN()  if((gras_if_SG()&&(gras_bench_once_begin(__FILE__, __LINE__)))||(gras_if_RL())) { 
42 /** \brief Stop benchmarking this part of the code
43     \hideinitializer */
44 #define GRAS_BENCH_ONCE_RUN_ONCE_END()    } GRAS_BENCH_ONCE_RUN_ALWAYS_END();
45
46 END_DECL()
47
48 #endif /* GRAS_CHRONO_H */