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