2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FUiEffects_LoggingProfiler.h
19 * @brief This is the header file for the profiling defines
22 #ifndef FUIEXTEFF3D_ELOGPROFILER_H_
23 #define FUIEXTEFF3D_ELOGPROFILER_H_
31 #ifndef CLOCK_MONOTONIC_RAW
32 #error Undefined CLOCK_MONOTONIC_RAW
34 #define HIRES_COUNTER_ID CLOCK_MONOTONIC_RAW
36 #error Unknown platform
39 namespace Tizen { namespace Ui { namespace Effects { namespace _EffectsLogging
42 #define START_PROFILER(Name)\
43 static timespec Name##_prof_t1, Name##_prof_t2;\
44 static long Name##_prof_dt = 0;\
45 clock_gettime(HIRES_COUNTER_ID, &Name##_prof_t1);
47 #define END_PROFILER(Name) \
48 clock_gettime(HIRES_COUNTER_ID, &Name##_prof_t2); \
49 Name##_prof_dt = (Name##_prof_t2.tv_sec - Name##_prof_t1.tv_sec) * 1000000 + (Name##_prof_t2.tv_nsec - Name##_prof_t1.tv_nsec) / 1000; \
50 SysLog(NID_UI_EFFECT, #Name" = %.3f ms", (float) Name##_prof_dt * 0.001f);
52 #define PROFILER_EXPR(expression, Name) \
53 START_PROFILER(Name) \
57 #define PROFILER_EXPR0(expression, Name) expression
60 #define START_PROFILER_AV(Name, N) \
61 static timespec Name##_prof_av_t1, Name##_prof_av_t2; \
62 static long Name##_prof_av_tmin = 999999999, Name##_prof_av_tmax = -1;\
63 static long Name##_prof_av_dt = 0;\
64 static unsigned int Name##_prof_av_count = N, Name##_prof_av_N = N; \
65 clock_gettime(HIRES_COUNTER_ID, &Name##_prof_av_t1);
67 #define END_PROFILER_AV(Name) \
68 if (Name##_prof_av_count > 0) \
70 clock_gettime(HIRES_COUNTER_ID, &Name##_prof_av_t2); \
71 long dt = (Name##_prof_av_t2.tv_sec - Name##_prof_av_t1.tv_sec) * 1000000 + (Name##_prof_av_t2.tv_nsec - Name##_prof_av_t1.tv_nsec) / 1000;\
72 if(dt > Name##_prof_av_tmax) Name##_prof_av_tmax = dt; \
73 if(dt < Name##_prof_av_tmin) Name##_prof_av_tmin = dt; \
74 Name##_prof_av_dt += dt; \
75 Name##_prof_av_count--; \
79 SysLog(NID_UI_EFFECT, #Name" = %.3f ms (min = %.3f, max = %.3f)", float(Name##_prof_av_dt / Name##_prof_av_N) * 0.001f, (float) Name##_prof_av_tmin * 0.001f, (float) Name##_prof_av_tmax * 0.001f);\
80 Name##_prof_av_count = Name##_prof_av_N;\
81 Name##_prof_av_dt = 0; \
82 Name##_prof_av_tmin = 999999999; \
83 Name##_prof_av_tmax = -1;\
86 #define PROFILER_EXPR_AV(expression, Name, N) \
87 START_PROFILER_AV(Name, N) \
91 #define PROFILER_EXPR_AV0(expression, Name, N) expression
94 #define PROFILER_CHECKPOINT(Name, N) \
95 static timespec Name##_prof_checkp_t1, Name##_prof_checkp_t2;\
96 static long Name##_prof_checkp_tmin = 999999999, Name##_prof_checkp_tmax = -1;\
97 static long Name##_prof_checkp_dt = 0;\
98 static unsigned int Name##_prof_checkp_count = 0, Name##_prof_checkp_N = N;\
100 if (Name##_prof_checkp_count > 0) \
102 clock_gettime(HIRES_COUNTER_ID, &Name##_prof_checkp_t2); \
103 long dt = (Name##_prof_checkp_t2.tv_sec - Name##_prof_checkp_t1.tv_sec) * 1000000 + (Name##_prof_checkp_t2.tv_nsec - Name##_prof_checkp_t1.tv_nsec) / 1000; \
104 clock_gettime(HIRES_COUNTER_ID, &Name##_prof_checkp_t1); \
105 if(dt > Name##_prof_checkp_tmax) Name##_prof_checkp_tmax = dt; \
106 if(dt < Name##_prof_checkp_tmin) Name##_prof_checkp_tmin = dt; \
107 Name##_prof_checkp_dt += dt; \
108 Name##_prof_checkp_count--; \
112 clock_gettime(HIRES_COUNTER_ID, &Name##_prof_checkp_t1); \
113 SysLog(NID_UI_EFFECT, #Name" = %.3f ms (min = %.3f, max = %.3f)", float(Name##_prof_checkp_dt / Name##_prof_checkp_N) * 0.001f, (float) Name##_prof_checkp_tmin * 0.001f, (float) Name##_prof_checkp_tmax * 0.001f);\
114 Name##_prof_checkp_count = Name##_prof_checkp_N;\
115 Name##_prof_checkp_dt = 0;\
116 Name##_prof_checkp_tmin = 999999999; \
117 Name##_prof_checkp_tmax = -1;\
120 } } } } // Tizen::Ui::Effects::_EffectsLogging
122 #define START_PROFILER(Name)
123 #define END_PROFILER(Name)
124 #define PROFILER_EXPR(expression, Name) expression
125 #define PROFILER_EXPR0(expression, Name) expression
127 #define START_PROFILER_AV(Name, N)
128 #define END_PROFILER_AV(Name)
129 #define PROFILER_EXPR_AV(expression, Name, N) expression
130 #define PROFILER_EXPR_AV0(expression, Name, N) expression
132 #define PROFILER_CHECKPOINT(Name, N)
133 #endif //USE_PROFILER
135 #endif // FUIEXTEFF3D_ELOGPROFILER_H_