Fix build warning
[platform/core/appfw/xdgmime.git] / test / perf.h
1 /*
2  * perf.h
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jayoun Lee                          <airjany@samsung.com>
7  * Contact: Seokkyu Jang                        <seokkyu.jang@samsung.com>
8  * Contact: Sangil Yoon                         <si83.yoon@samsung.com>
9  *
10  * This library is free software; you can redistribute it and/or modify it under
11  * the terms of the GNU Lesser General Public License as published by the
12  * Free Software Foundation; either version 2.1 of the License, or (at your option)
13  * any later version.
14  *
15  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
16  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18  * License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this library; if not, write to the Free Software Foundation, Inc., 51
22  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25
26 #ifndef __PERF_H__
27 #define __PERF_H__
28
29 #ifdef PERF_ACTIVATE
30
31 #include <sys/time.h>
32 static struct timeval __g_base_time = {
33         .tv_sec = 0,
34         .tv_usec = 0
35 };
36
37 #define INIT_PERF(kb)\
38 do{\
39         struct timeval tv;\
40         gettimeofday(&tv, NULL);\
41         __g_base_time.tv_sec = tv.tv_sec;\
42         __g_base_time.tv_usec = tv.tv_usec;\
43 }while(0);
44
45 #define PERF(fmt,arg...)\
46 do{\
47         struct timeval cur;\
48         struct timeval res;\
49         gettimeofday(&cur,NULL);\
50         if(__g_base_time.tv_sec != 0){\
51                 timersub(&cur, &__g_base_time, &res);\
52                 printf("%c[1;31m[%s,%d] %u sec %u msec "fmt" %c[0m\n",\
53                         27,__FUNCTION__,__LINE__,\
54                                 res.tv_sec,res.tv_usec/1000,##arg,27);\
55         }\
56 }while(0);
57
58 #else
59
60 #define INIT_PERF(kb)
61 #define PERF(fmt,arg...) 
62
63 #endif
64
65 #endif