Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- add 'flog_if_slow' macro

  • Loading branch information...
commit a6bf4054fcd09c31750d25e836b8441b3c310ecb 1 parent fc2b518
@jordansissel jordansissel authored
Showing with 13 additions and 0 deletions.
  1. +13 −0 flog.h
View
13 flog.h
@@ -5,4 +5,17 @@
void flog(FILE *stream, const char *format, ...);
double duration(struct timeval *start);
+#define flog_if_slow(stream, max_duration, block, format, args...) \
+{ \
+ struct timeval __start; \
+ gettimeofday(&__start, NULL); \
+ { \
+ block \
+ } \
+ double __duration = duration(&__start); \
+ if (__duration >= max_duration) { \
+ flog(stream, "slow operation (%.3f seconds): " format , __duration, args); \
+ } \
+}
+
#endif /* _FLOG_H_ */
Please sign in to comment.
Something went wrong with that request. Please try again.