summaryrefslogtreecommitdiff
path: root/source3/include/profile.h
diff options
context:
space:
mode:
Diffstat (limited to 'source3/include/profile.h')
-rw-r--r--source3/include/profile.h72
1 files changed, 61 insertions, 11 deletions
diff --git a/source3/include/profile.h b/source3/include/profile.h
index 9b6ec462df..d18f598021 100644
--- a/source3/include/profile.h
+++ b/source3/include/profile.h
@@ -22,6 +22,14 @@
*/
+/*
+ * Reasons for cache flush.
+ */
+
+#define NUM_FLUSH_REASONS 8 /* Keep this in sync with the enum below. */
+enum flush_reason_enum { SEEK_FLUSH, READ_FLUSH, WRITE_FLUSH, READRAW_FLUSH,
+ OPLOCK_RELEASE_FLUSH, CLOSE_FLUSH, SYNC_FLUSH, SIZECHANGE_FLUSH };
+
/* this file defines the profile structure in the profile shared
memory area */
@@ -308,19 +316,61 @@ struct profile_struct {
extern struct profile_struct *profile_p;
+extern struct timeval profile_starttime;
+extern struct timeval profile_endtime;
+extern BOOL do_profile_flag;
-#define INC_PROFILE_COUNT(x) if (profile_p) profile_p->x++
-#define DEC_PROFILE_COUNT(x) if (profile_p) profile_p->x--
-#define ADD_PROFILE_COUNT(x,y) if (profile_p) profile_p->x += (y)
+/* these are helper macros - do not call them directly in the code
+ * use the DO_PROFILE_* START_PROFILE and END_PROFILE ones
+ * below which test for the profile flage first
+ */
+#define INC_PROFILE_COUNT(x) profile_p->x++
+#define DEC_PROFILE_COUNT(x) profile_p->x--
+#define ADD_PROFILE_COUNT(x,y) profile_p->x += (y)
+#define PROFILE_TIME TvalDiff(&profile_starttime,&profile_endtime)
+#ifdef WITH_PROFILE
+#define DO_PROFILE_INC(x) \
+ if (do_profile_flag) { \
+ INC_PROFILE_COUNT(x); \
+ }
+#define DO_PROFILE_DEC(x) \
+ if (do_profile_flag) { \
+ DEC_PROFILE_COUNT(x); \
+ }
+#define DO_PROFILE_DEC_INC(x,y) \
+ if (do_profile_flag) { \
+ DEC_PROFILE_COUNT(x); \
+ INC_PROFILE_COUNT(y); \
+ }
+#define DO_PROFILE_ADD(x,n) \
+ if (do_profile_flag) { \
+ ADD_PROFILE_COUNT(x,n); \
+ }
#define START_PROFILE(x) \
- struct timeval starttime; \
- struct timeval endtime; \
- GetTimeOfDay(&starttime); \
- INC_PROFILE_COUNT(x##_count)
-
-#define END_PROFILE(y) \
- GetTimeOfDay(&endtime); \
- ADD_PROFILE_COUNT((y##_time),TvalDiff(&starttime,&endtime))
+ if (do_profile_flag) { \
+ GetTimeOfDay(&profile_starttime); \
+ INC_PROFILE_COUNT(x##_count); \
+ }
+#define START_PROFILE_BYTES(x,n) \
+ if (do_profile_flag) { \
+ GetTimeOfDay(&profile_starttime); \
+ INC_PROFILE_COUNT(x##_count); \
+ ADD_PROFILE_COUNT(x##_bytes,n); \
+ }
+#define END_PROFILE(x) \
+ if (do_profile_flag) { \
+ GetTimeOfDay(&profile_endtime); \
+ ADD_PROFILE_COUNT(x##_time,PROFILE_TIME); \
+ }
+#else
+#define DO_PROFILE_INC(x)
+#define DO_PROFILE_DEC(x)
+#define DO_PROFILE_DEC_INC(x,y)
+#define DO_PROFILE_ADD(x,n)
+#define START_PROFILE(x)
+#define START_PROFILE_BYTES(x,n)
+#define END_PROFILE(x)
+#endif
#endif