summaryrefslogtreecommitdiff
path: root/source3/profile
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/profile
parent256690098256dc5205ae246ff49de10324defdf6 (diff)
downloadsamba-826614ed16e0fb23d30305990dbfa357b4366de2.tar.gz
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/profile')
-rw-r--r--source3/profile/profile.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/source3/profile/profile.c b/source3/profile/profile.c
index db8a643042b..bacf00eb017 100644
--- a/source3/profile/profile.c
+++ b/source3/profile/profile.c
@@ -28,6 +28,9 @@
#ifdef WITH_PROFILE
static int shm_id;
static BOOL read_only;
+#if defined(HAVE_CLOCK_GETTIME)
+clockid_t __profile_clock;
+#endif
#endif
struct profile_header *profile_h;
@@ -103,6 +106,24 @@ BOOL profile_setup(BOOL rdonly)
read_only = rdonly;
+#if defined(HAVE_CLOCK_GETTIME)
+ if (this_is_smp()) {
+ /* This is faster that gettimeofday, but not fast enough to
+ * leave it enabled in production.
+ */
+ __profile_clock = CLOCK_MONOTONIC;
+ } else {
+ /* CLOCK_PROCESS_CPUTIME_ID is sufficiently fast that the
+ * always profiling times is plausible. Unfortunately it is
+ * only accurate if we can guarantee we will not be scheduled
+ * onto a different CPU between samples. Until there is some
+ * way to set processor affinity, we can only use this on
+ * uniprocessors.
+ */
+ __profile_clock = CLOCK_PROCESS_CPUTIME_ID;
+ }
+#endif
+
again:
/* try to use an existing key */
shm_id = shmget(PROF_SHMEM_KEY, 0, 0);