2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
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.
23 #define CAM_TA_MAX_CHECKPOINT 500
24 #define CAM_TA_MAX_ACCUM 500
26 typedef struct _cam_ta_checkpoint {
27 unsigned long timestamp;
31 typedef struct _cam_ta_accum_item {
32 unsigned long elapsed_accum;
33 unsigned long num_calls;
34 unsigned long elapsed_min;
35 unsigned long elapsed_max;
36 unsigned long first_start;
37 unsigned long last_end;
41 unsigned long timestamp;
46 #define CAM_TA_SHOW_STDOUT 0
47 #define CAM_TA_SHOW_STDERR 1
48 #define CAM_TA_SHOW_FILE 2
49 #define CAM_TA_RESULT_FILE "/tmp/cam-ta.log"
51 int cam_ta_init(void);
52 int cam_ta_release(void);
53 void cam_ta_set_enable(int enable);
54 char *cam_ta_fmt(const char *fmt, ...);
56 int cam_ta_add_checkpoint(char *name, int show, char *filename, int line);
57 void cam_ta_show_checkpoints(void);
58 void cam_ta_show_diff(char *name1, char *name2);
60 int cam_ta_get_numof_checkpoints();
61 unsigned long cam_ta_get_diff(char *name1, char *name2);
62 char *cam_ta_get_name(int idx);
64 int cam_ta_accum_item_begin(char *name, int show, char *filename, int line);
65 int cam_ta_accum_item_end(char *name, int show, char *filename, int line);
66 void cam_ta_accum_show_result(int direction);
68 #define CAM_TA_INIT() (cam_ta_init())
69 #define CAM_TA_RELEASE() (cam_ta_release())
70 #define CAM_TA_SET_ENABLE(enable) (cam_ta_set_enable(enable))
72 #define CAM_TA_ADD_CHECKPOINT(name, show) (cam_ta_add_checkpoint(name, show, __FILE__, __LINE__))
73 #define CAM_TA_SHOW_CHECKPOINTS() (cam_ta_show_checkpoints())
74 #define CAM_TA_SHOW_DIFF(name1, name2) (cam_ta_show_diff(name1, name2))
75 #define CAM_TA_GET_NUMOF_CHECKPOINTS() (cam_ta_get_numof_checkpoints())
76 #define CAM_TA_GET_DIFF(name1, name2) (cam_ta_get_diff(name1, name2))
77 #define CAM_TA_GET_NAME(idx) (cam_ta_get_name(idx))
79 #define CAM_TA_ACUM_ITEM_BEGIN(name, show) (cam_ta_accum_item_begin(name, show, __FILE__, __LINE__))
80 #define CAM_TA_ACUM_ITEM_END(name, show) (cam_ta_accum_item_end(name, show, __FILE__, __LINE__))
81 #define CAM_TA_ACUM_ITEM_SHOW_RESULT() (cam_ta_accum_show_result(CAM_TA_SHOW_STDOUT))
82 #define CAM_TA_ACUM_ITEM_SHOW_RESULT_TO(x) (cam_ta_accum_show_result(x))
84 #define __cam_ta__(name, x) \
85 CAM_TA_ACUM_ITEM_BEGIN(name, 0); \
87 CAM_TA_ACUM_ITEM_END(name, 0);
89 #define __cam_tafmt__(fmt, args...) (cam_ta_fmt(fmt, ##args))
94 #define CAM_TA_RELEASE()
95 #define CAM_TA_SET_ENABLE(enable)
97 #define CAM_TA_ADD_CHECKPOINT(name, show)
98 #define CAM_TA_SHOW_CHECKPOINTS()
99 #define CAM_TA_SHOW_DIFF(name1, name2)
100 #define CAM_TA_GET_NUMOF_CHECKPOINTS()
101 #define CAM_TA_GET_DIFF(name1, name2)
102 #define CAM_TA_GET_NAME(idx)
104 #define CAM_TA_ACUM_ITEM_BEGIN(name, show)
105 #define CAM_TA_ACUM_ITEM_END(name, show)
106 #define CAM_TA_ACUM_ITEM_SHOW_RESULT()
107 #define CAM_TA_ACUM_ITEM_SHOW_RESULT_TO(x)
108 #define __cam_ta__(name, x) x
109 #define __cam_tafmt__(fmt, args...)