From 826614ed16e0fb23d30305990dbfa357b4366de2 Mon Sep 17 00:00:00 2001 From: James Peach Date: Mon, 8 May 2006 03:20:49 +0000 Subject: r15508: Use clock_gettime for profiling timstamps if it is available. Use the fastest clock available on uniprocessors. (This used to be commit d44862928206b524f826bd7c2997ab5353c0b6a0) --- source3/include/smbprofile.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source3/include/smbprofile.h') 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) \ -- cgit