Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fd570c884afbde047ff2da06440b4230206a5b5a
[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 int gras_bench_always_begin(const char *location, int line);
20 int gras_bench_always_end(void);
21 int gras_bench_once_begin(const char *location, int line);
22 int gras_bench_once_end(void);
23
24 /** \brief Start benchmark this part of the code
25     \hideinitializer */
26 #define GRAS_BENCH_ALWAYS_BEGIN()  do { if(gras_if_SG()) gras_bench_always_begin(__FILE__, __LINE__); } while(0)
27 /** \brief Stop benchmark this part of the code
28     \hideinitializer */
29 #define GRAS_BENCH_ALWAYS_END() do { if(gras_if_SG()) gras_bench_always_end(); } while(0)
30
31 /** \brief Start benchmark this part of the code if it has never been benchmarked before
32     \hideinitializer */
33 #define GRAS_BENCH_ONCE_RUN_ALWAYS_BEGIN()  do { if(gras_if_SG()) gras_bench_once_begin(__FILE__, __LINE__); } while(0)
34 /** \brief Stop benchmarking this part of the code
35     \hideinitializer */
36 #define GRAS_BENCH_ONCE_RUN_ALWAYS_END()    do { if(gras_if_SG()) gras_bench_once_end(); } while(0)
37
38 /** \brief Start benchmark this part of the code if it has never been benchmarked before
39     \hideinitializer */
40 #define GRAS_BENCH_ONCE_RUN_ONCE_BEGIN()  if((gras_if_SG()&&(gras_bench_once_begin(__FILE__, __LINE__)))||(gras_if_RL())) { 
41 /** \brief Stop benchmarking this part of the code
42     \hideinitializer */
43 #define GRAS_BENCH_ONCE_RUN_ONCE_END()    } GRAS_BENCH_ONCE_RUN_ALWAYS_END();
44
45 END_DECL()
46
47 #endif /* GRAS_CHRONO_H */