From 6bc3d994966b00560e07c662b33da0cc9477891f Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 21 Jul 2015 22:26:48 +0100 Subject: [PATCH] [profile] Add profile_custom() for profiling with arbitrary time units Provide profile_custom() as a trivial wrapper around profile_update() to allow for the use of the profiling infrastructure by code using timers other than the default profile_timestamp() provider. Signed-off-by: Michael Brown --- src/include/ipxe/profile.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/include/ipxe/profile.h b/src/include/ipxe/profile.h index 5d3b6624..b6d2b19e 100644 --- a/src/include/ipxe/profile.h +++ b/src/include/ipxe/profile.h @@ -186,4 +186,18 @@ profile_exclude ( struct profiler *profiler ) { profile_excluded += profile_elapsed ( profiler ); } +/** + * Record profiling sample in custom units + * + * @v profiler Profiler + * @v sample Profiling sample + */ +static inline __attribute__ (( always_inline )) void +profile_custom ( struct profiler *profiler, unsigned long sample ) { + + /* If profiling is active then update stats */ + if ( PROFILING ) + profile_update ( profiler, sample ); +} + #endif /* _IPXE_PROFILE_H */