2 * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 static struct timespec __g_base_time = {
29 #define INIT_PERF(kb) do { \
32 tmp = bundle_get_val(kb, AUL_K_STARTTIME); \
34 sscanf(tmp, "%ld/%ld", &tv.tv_sec, &tv.tv_nsec); \
36 clock_gettime(CLOCK_MONOTONIC, &tv); \
37 __g_base_time.tv_sec = tv.tv_sec; \
38 __g_base_time.tv_nsec = tv.tv_nsec; \
41 #define PERF(fmt, arg...) do { \
42 struct timespec cur; \
43 struct timespec res; \
44 clock_gettime(CLOCK_MONOTONIC, &cur); \
45 if (__g_base_time.tv_sec != 0) { \
46 res->tv_sec = cur.tv_sec - __g_base_time.tv_sec; \
47 res->tv_nsec = cur.tv_nsec - __g_base_time.tv_nsec; \
48 printf("%c[1;31m[%s,%d] %ld sec %ld msec "fmt \
49 " %c[0m\n", 27, __func__, \
50 __LINE__, res.tv_sec, \
51 res.tv_nsec / 1e6, ##arg, 27); \
58 #define PERF(fmt, arg...)
62 #endif /* __PERF_H__ */