Merging r46111 through r46136 from trunk into soc-2011-tomato
[blender-staging.git] / source / blender / blenlib / PIL_time.h
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19  * All rights reserved.
20  *
21  * The Original Code is: all of this file.
22  *
23  * Contributor(s): none yet.
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 /** \file blender/blenlib/PIL_time.h
29  *  \ingroup bli
30  *  \brief Platform independent time functions.
31  */
32
33  
34 #ifndef __PIL_TIME_H__
35 #define __PIL_TIME_H__
36
37 #ifdef __cplusplus
38 extern "C" { 
39 #endif
40
41 extern 
42         /** Return an indication of time, expressed     as
43          * seconds since some fixed point. Successive calls
44          * are guaranteed to generate values greater than or
45          * equal to the last call.
46          */
47 double  PIL_check_seconds_timer         (void);
48
49         /**
50          * Platform-independent sleep function.
51          * \param ms Number of milliseconds to sleep
52          */
53 void    PIL_sleep_ms                            (int ms);
54
55 /** Utility defines for timing.
56  * requires BLI_utildefines.h for 'AT'
57  * TIMEIT_VALUE returns the time since TIMEIT_START was called.
58  */
59 #define TIMEIT_START(var)                                                                                                       \
60 {                                                                                                                                                       \
61         double _timeit_##var= PIL_check_seconds_timer();                                                \
62         printf("time start (" #var "):  " AT "\n");                                                             \
63         fflush(stdout);                                                                                                                 \
64         {                                                                                                                                               \
65
66
67 #define TIMEIT_VALUE(var) (float)(PIL_check_seconds_timer() - _timeit_##var)
68
69
70 #define TIMEIT_END(var)                                                                                                         \
71         }                                                                                                                                               \
72         printf("time end   (" #var "): %.6f" "  " AT "\n",      TIMEIT_VALUE(var));     \
73         fflush(stdout);                                                                                                                 \
74 }                                                                                                                                                       \
75
76 #ifdef __cplusplus
77 }
78 #endif
79
80 #endif /* !__PIL_TIME_H__ */