4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
23 #include <asm/unistd.h>
26 #include "media-svc-debug.h"
28 #ifdef _PERFORMANCE_CHECK_
29 static long g_time_usec = 0L;
33 static FILE *g_log_fp = NULL;
34 static char _g_file_path[1024] = "\0";
41 void mediainfo_init_file_debug()
43 if (g_log_fp == NULL) {
44 snprintf(_g_file_path, sizeof(_g_file_path), "/tmp/%s", "media-info");
45 if (access(_g_file_path, R_OK == 0)) {
49 g_log_fp = fopen(_g_file_path, "a");
53 void mediainfo_close_file_debug()
55 if (g_log_fp != NULL) {
63 long mediainfo_get_debug_time(void)
65 #ifdef _PERFORMANCE_CHECK_
67 gettimeofday(&time, NULL);
68 return time.tv_sec * 1000000 + time.tv_usec;
74 void mediainfo_reset_debug_time(void)
76 #ifdef _PERFORMANCE_CHECK_
78 gettimeofday(&time, NULL);
79 g_time_usec = time.tv_sec * 1000000 + time.tv_usec;
83 void mediainfo_print_debug_time(char *time_string)
85 #ifdef _PERFORMANCE_CHECK_
87 double totaltime = 0.0;
89 gettimeofday(&time, NULL);
90 totaltime = (double)(time.tv_sec * 1000000 + time.tv_usec - g_time_usec) / CLOCKS_PER_SEC;
92 media_svc_debug("time [%s] : %f", time_string, totaltime);
97 mediainfo_print_debug_time_ex(long start, long end, const char *func_name, char *time_string)
99 #ifdef _PERFORMANCE_CHECK_
100 double totaltime = 0.0;
102 totaltime = (double)(end - start) / CLOCKS_PER_SEC;
104 media_svc_debug("time [%s: %s] : %f", func_name, time_string, totaltime);