summaryrefslogtreecommitdiff
path: root/source3/include
diff options
context:
space:
mode:
authorJames Peach <jpeach@samba.org>2006-05-08 03:20:49 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:16:55 -0500
commit826614ed16e0fb23d30305990dbfa357b4366de2 (patch)
tree924ca53959929f394ca662b9385280c10e7610c9 /source3/include
parent256690098256dc5205ae246ff49de10324defdf6 (diff)
downloadsamba-826614ed16e0fb23d30305990dbfa357b4366de2.tar.gz
samba-826614ed16e0fb23d30305990dbfa357b4366de2.tar.bz2
samba-826614ed16e0fb23d30305990dbfa357b4366de2.zip
r15508: Use clock_gettime for profiling timstamps if it is available. Use
the fastest clock available on uniprocessors. (This used to be commit d44862928206b524f826bd7c2997ab5353c0b6a0)
Diffstat (limited to 'source3/include')
-rw-r--r--source3/include/smbprofile.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/source3/include/smbprofile.h b/source3/include/smbprofile.h
index dd171ac13e..fb5fa078c1 100644
--- a/source3/include/smbprofile.h
+++ b/source3/include/smbprofile.h
@@ -419,6 +419,25 @@ extern BOOL do_profile_times;
#define DEC_PROFILE_COUNT(x) profile_p->x--
#define ADD_PROFILE_COUNT(x,y) profile_p->x += (y)
+#if defined(HAVE_CLOCK_GETTIME)
+
+extern clockid_t __profile_clock;
+
+static inline unsigned long long profile_timestamp(void)
+{
+ struct timespec ts;
+
+ /* FIXME: On a single-CPU system, or a system where we have bound
+ * daemon threads to single CPUs (eg. using cpusets or processor
+ * affinity), it might be preferable to use CLOCK_PROCESS_CPUTIME_ID.
+ */
+
+ clock_gettime(__profile_clock, &ts);
+ return (ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); /* usec */
+}
+
+#else
+
static inline unsigned long long profile_timestamp(void)
{
struct timeval tv;
@@ -426,6 +445,8 @@ static inline unsigned long long profile_timestamp(void)
return (tv.tv_sec * 1000000) + tv.tv_usec;
}
+#endif
+
/* end of helper macros */
#define DO_PROFILE_INC(x) \