3 /* chrono.h - timer macros for GRAS */
5 /* Copyright (c) 2005 Martin Quinson, Arnaud Legrand. All rights reserved. */
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. */
15 #include "gras/cond.h"
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);
24 /** \brief Start benchmark this part of the code
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
29 #define GRAS_BENCH_ALWAYS_END() do { if(gras_if_SG()) gras_bench_always_end(); } while(0)
31 /** \brief Start benchmark this part of the code if it has never been benchmarked before
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
36 #define GRAS_BENCH_ONCE_RUN_ALWAYS_END() do { if(gras_if_SG()) gras_bench_once_end(); } while(0)
38 /** \brief Start benchmark this part of the code if it has never been benchmarked before
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
43 #define GRAS_BENCH_ONCE_RUN_ONCE_END() } GRAS_BENCH_ONCE_RUN_ALWAYS_END();
47 #endif /* GRAS_CHRONO_H */