]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[profile] Add profile_custom() for profiling with arbitrary time units
authorMichael Brown <mcb30@ipxe.org>
Tue, 21 Jul 2015 21:26:48 +0000 (22:26 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 22 Jul 2015 20:17:47 +0000 (21:17 +0100)
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 <mcb30@ipxe.org>
src/include/ipxe/profile.h

index 5d3b662416caf1cea7e5cab7afde0fc1a3694d17..b6d2b19e03483f2a90adf411b86df077bc7ebfa0 100644 (file)
@@ -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 */