summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe
diff options
context:
space:
mode:
authorMichael Brown2014-05-03 19:25:19 +0200
committerMichael Brown2014-05-03 19:50:26 +0200
commita0da06c306f4c106136909ad149204005fe82ab1 (patch)
tree2278e138c0d70ee4f950fd0e4587149184f6dd45 /src/include/ipxe
parent[librm] Speed up protected-mode calls under KVM (diff)
downloadipxe-a0da06c306f4c106136909ad149204005fe82ab1.tar.gz
ipxe-a0da06c306f4c106136909ad149204005fe82ab1.tar.xz
ipxe-a0da06c306f4c106136909ad149204005fe82ab1.zip
[profile] Provide methods for profiling individual stages of operations
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe')
-rw-r--r--src/include/ipxe/profile.h42
1 files changed, 35 insertions, 7 deletions
diff --git a/src/include/ipxe/profile.h b/src/include/ipxe/profile.h
index 0b15fe54..d4fc4f90 100644
--- a/src/include/ipxe/profile.h
+++ b/src/include/ipxe/profile.h
@@ -9,7 +9,6 @@
FILE_LICENCE ( GPL2_OR_LATER );
-#include <stdint.h>
#include <bits/profile.h>
#include <ipxe/tables.h>
@@ -26,7 +25,9 @@ struct profiler {
/** Name */
const char *name;
/** Start timestamp */
- uint64_t started;
+ unsigned long started;
+ /** Stop timestamp */
+ unsigned long stopped;
/** Number of samples */
unsigned int count;
/** Mean sample value (scaled) */
@@ -66,29 +67,56 @@ extern unsigned long profile_stddev ( struct profiler *profiler );
* Start profiling
*
* @v profiler Profiler
+ * @v started Start timestamp
+ */
+static inline __attribute__ (( always_inline )) void
+profile_start_at ( struct profiler *profiler, unsigned long started ) {
+
+ /* If profiling is active then record start timestamp */
+ if ( PROFILING )
+ profiler->started = started;
+}
+
+/**
+ * Start profiling
+ *
+ * @v profiler Profiler
*/
static inline __attribute__ (( always_inline )) void
profile_start ( struct profiler *profiler ) {
/* If profiling is active then record start timestamp */
if ( PROFILING )
- profiler->started = profile_timestamp();
+ profile_start_at ( profiler, profile_timestamp() );
}
/**
* Record profiling result
*
* @v profiler Profiler
+ * @v stopped Stop timestamp
*/
static inline __attribute__ (( always_inline )) void
-profile_stop ( struct profiler *profiler ) {
- uint64_t ended;
+profile_stop_at ( struct profiler *profiler, unsigned long stopped ) {
/* If profiling is active then record end timestamp and update stats */
if ( PROFILING ) {
- ended = profile_timestamp();
- profile_update ( profiler, ( ended - profiler->started ) );
+ profiler->stopped = stopped;
+ profile_update ( profiler, ( stopped - profiler->started ) );
}
}
+/**
+ * Record profiling result
+ *
+ * @v profiler Profiler
+ */
+static inline __attribute__ (( always_inline )) void
+profile_stop ( struct profiler *profiler ) {
+
+ /* If profiling is active then record end timestamp and update stats */
+ if ( PROFILING )
+ profile_stop_at ( profiler, profile_timestamp() );
+}
+
#endif /* _IPXE_PROFILE_H */