s3-profile: add PROFILE_TIMESTAMP macro
authorUri Simchoni <uri@samba.org>
Mon, 28 Mar 2016 07:13:50 +0000 (10:13 +0300)
committerJeremy Allison <jra@samba.org>
Mon, 28 Mar 2016 18:45:16 +0000 (20:45 +0200)
This is a get-timestamp macro which works only when
profiling is enabled in the build. The underlying
clock_gettime_mono() function can be costly on some
architectures and we want to avoid it if it's not
necessary.

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/include/smbprofile.h

index 9d0256313e4a5bde83916e68f99c853c1174c702..1183af6a0bfc79a157899868bfb2f1d98e8fbc88 100644 (file)
@@ -565,6 +565,8 @@ static inline uint64_t profile_timestamp(void)
 #define END_PROFILE_BYTES(x) \
        SMBPROFILE_BYTES_ASYNC_END(__profasync_##x)
 
+#define PROFILE_TIMESTAMP(x) clock_gettime_mono(x)
+
 #else /* WITH_PROFILE */
 
 #define SMBPROFILE_COUNT_INCREMENT(_name, _area, _v)
@@ -595,6 +597,8 @@ static inline uint64_t profile_timestamp(void)
 #define END_PROFILE(x)
 #define END_PROFILE_BYTES(x)
 
+#define PROFILE_TIMESTAMP(x) (*(x)=(struct timespec){0})
+
 static inline bool smbprofile_dump_pending(void)
 {
        return false;