* limitations under the License.
*/
-
#ifndef __PERF_H__
#define __PERF_H__
#include <sys/time.h>
static struct timeval __g_base_time = {
- .tv_sec = 0,
- .tv_usec = 0
+ .tv_sec = 0,
+ .tv_usec = 0
};
-#define INIT_PERF(kb)\
-do {\
- const char *tmp;\
- struct timeval tv;\
- tmp = bundle_get_val(kb, AUL_K_STARTTIME);\
- if (tmp != NULL)\
- sscanf(tmp, "%ld/%ld", &tv.tv_sec, &tv.tv_usec);\
- else\
- gettimeofday(&tv, NULL);\
- __g_base_time.tv_sec = tv.tv_sec;\
- __g_base_time.tv_usec = tv.tv_usec;\
-} while (0);
-
-#define PERF(fmt, arg...)\
-do {\
- struct timeval cur;\
- struct timeval res;\
- gettimeofday(&cur, NULL);\
- if (__g_base_time.tv_sec != 0) {\
- timersub(&cur, &__g_base_time, &res);\
- printf("%c[1;31m[%s,%d] %ld sec %ld msec "fmt" %c[0m\n",\
- 27, __FUNCTION__, __LINE__, \
- res.tv_sec, res.tv_usec/1000, ##arg, 27);\
- } \
-} while (0);
+#define INIT_PERF(kb) \
+ do { \
+ const char *tmp; \
+ struct timeval tv; \
+ tmp = bundle_get_val(kb, AUL_K_STARTTIME); \
+ if (tmp != NULL) { \
+ sscanf(tmp, "%ld/%ld", &tv.tv_sec, &tv.tv_usec); } \
+ else { \
+ gettimeofday(&tv, NULL); } \
+ __g_base_time.tv_sec = tv.tv_sec; \
+ __g_base_time.tv_usec = tv.tv_usec; \
+ } while (0);
+
+#define PERF(fmt, arg ...) \
+ do { \
+ struct timeval cur; \
+ struct timeval res; \
+ gettimeofday(&cur, NULL); \
+ if (__g_base_time.tv_sec != 0) { \
+ timersub(&cur, &__g_base_time, &res); \
+ printf("%c[1;31m[%s,%d] %ld sec %ld msec "fmt " %c[0m\n", \
+ 27, __FUNCTION__, __LINE__, \
+ res.tv_sec, res.tv_usec / 1000,##arg, 27); \
+ } \
+ } while (0);
#else
#define INIT_PERF(kb)
-#define PERF(fmt, arg...)
+#define PERF(fmt, arg ...)
#endif