1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 2001,2002,2003 Bastien Nocera <hadess@hadess.net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
18  *
19  *
20  * The Totem project hereby grant permission for non-gpl compatible GStreamer
21  * plugins to be used and distributed together with GStreamer and Totem. This
22  * permission are above and beyond the permissions granted by the GPL license
23  * Totem is covered by.
24  *
25  * Monday 7th February 2005: Christian Schaller: Add exception clause.
26  * See license_change file for details.
27  *
28  */
29 
30 #ifndef __TOTEM_PROFILE_H__
31 #define __TOTEM_PROFILE_H__ 1
32 
33 #ifdef GNOME_ENABLE_DEBUG
34 
35 #include <sys/time.h>
36 #include <glib.h>
37 
38 #define TOTEM_PROFILE(function)     \
39     do{                             \
40       struct timeval current_time;  \
41       double dtime;                 \
42       gettimeofday(&current_time, NULL); \
43       dtime = -(current_time.tv_sec + (current_time.tv_usec / 1000000.0)); \
44       function;                     \
45       gettimeofday(&current_time, NULL); \
46       dtime += current_time.tv_sec + (current_time.tv_usec / 1000000.0); \
47       printf("(%s:%d) took %lf seconds\n", \
48 	     G_STRFUNC, __LINE__, dtime ); \
49     }while(0)
50 
51 #else /* GNOME_ENABLE_DEBUG */
52 
53 #define TOTEM_PROFILE(function) function
54 
55 #endif /* GNOME_ENABLE_DEBUG */
56 
57 #endif /* __TOTEM_PROFILE_H__ */
58