diff options
author | James Peach <jpeach@samba.org> | 2006-05-08 03:20:49 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:16:55 -0500 |
commit | d44862928206b524f826bd7c2997ab5353c0b6a0 (patch) | |
tree | dfad1a1b6f9a180bedc1bb5cd0704ba56bf370a5 /source/profile | |
parent | 800f4cd158c5de8a0031abf4d030f633d784999f (diff) | |
download | samba-d44862928206b524f826bd7c2997ab5353c0b6a0.tar.gz |
r15508: Use clock_gettime for profiling timstamps if it is available. Use
the fastest clock available on uniprocessors.
Diffstat (limited to 'source/profile')
-rw-r--r-- | source/profile/profile.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/source/profile/profile.c b/source/profile/profile.c index db8a643042b..bacf00eb017 100644 --- a/source/profile/profile.c +++ b/source/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); |