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-info-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",
46 if (access(_g_file_path, R_OK == 0)) {
50 g_log_fp = fopen(_g_file_path, "a");
54 void mediainfo_close_file_debug()
56 if (g_log_fp != NULL) {
64 long mediainfo_get_debug_time(void)
66 #ifdef _PERFORMANCE_CHECK_
68 gettimeofday(&time, NULL);
69 return time.tv_sec * 1000000 + time.tv_usec;
75 void mediainfo_reset_debug_time(void)
77 #ifdef _PERFORMANCE_CHECK_
79 gettimeofday(&time, NULL);
80 g_time_usec = time.tv_sec * 1000000 + time.tv_usec;
84 void mediainfo_print_debug_time(char *time_string)
86 #ifdef _PERFORMANCE_CHECK_
88 double totaltime = 0.0;
90 gettimeofday(&time, NULL);
92 (double)(time.tv_sec * 1000000 + time.tv_usec -
93 g_time_usec) / CLOCKS_PER_SEC;
95 mediainfo_dbg("time [%s] : %f \n", time_string, totaltime);
100 mediainfo_print_debug_time_ex(long start, long end, const char *func_name,
103 #ifdef _PERFORMANCE_CHECK_
104 double totaltime = 0.0;
106 totaltime = (double)(end - start) / CLOCKS_PER_SEC;
108 mediainfo_dbg("time [%s: %s] : %f \n", func_name, time_string,