|
@@ -9,7 +9,6 @@
|
9
|
9
|
|
10
|
10
|
FILE_LICENCE ( GPL2_OR_LATER );
|
11
|
11
|
|
12
|
|
-#include <stdint.h>
|
13
|
12
|
#include <bits/profile.h>
|
14
|
13
|
#include <ipxe/tables.h>
|
15
|
14
|
|
|
@@ -26,7 +25,9 @@ struct profiler {
|
26
|
25
|
/** Name */
|
27
|
26
|
const char *name;
|
28
|
27
|
/** Start timestamp */
|
29
|
|
- uint64_t started;
|
|
28
|
+ unsigned long started;
|
|
29
|
+ /** Stop timestamp */
|
|
30
|
+ unsigned long stopped;
|
30
|
31
|
/** Number of samples */
|
31
|
32
|
unsigned int count;
|
32
|
33
|
/** Mean sample value (scaled) */
|
|
@@ -62,6 +63,20 @@ extern unsigned long profile_mean ( struct profiler *profiler );
|
62
|
63
|
extern unsigned long profile_variance ( struct profiler *profiler );
|
63
|
64
|
extern unsigned long profile_stddev ( struct profiler *profiler );
|
64
|
65
|
|
|
66
|
+/**
|
|
67
|
+ * Start profiling
|
|
68
|
+ *
|
|
69
|
+ * @v profiler Profiler
|
|
70
|
+ * @v started Start timestamp
|
|
71
|
+ */
|
|
72
|
+static inline __attribute__ (( always_inline )) void
|
|
73
|
+profile_start_at ( struct profiler *profiler, unsigned long started ) {
|
|
74
|
+
|
|
75
|
+ /* If profiling is active then record start timestamp */
|
|
76
|
+ if ( PROFILING )
|
|
77
|
+ profiler->started = started;
|
|
78
|
+}
|
|
79
|
+
|
65
|
80
|
/**
|
66
|
81
|
* Start profiling
|
67
|
82
|
*
|
|
@@ -72,23 +87,36 @@ profile_start ( struct profiler *profiler ) {
|
72
|
87
|
|
73
|
88
|
/* If profiling is active then record start timestamp */
|
74
|
89
|
if ( PROFILING )
|
75
|
|
- profiler->started = profile_timestamp();
|
|
90
|
+ profile_start_at ( profiler, profile_timestamp() );
|
76
|
91
|
}
|
77
|
92
|
|
78
|
93
|
/**
|
79
|
94
|
* Record profiling result
|
80
|
95
|
*
|
81
|
96
|
* @v profiler Profiler
|
|
97
|
+ * @v stopped Stop timestamp
|
82
|
98
|
*/
|
83
|
99
|
static inline __attribute__ (( always_inline )) void
|
84
|
|
-profile_stop ( struct profiler *profiler ) {
|
85
|
|
- uint64_t ended;
|
|
100
|
+profile_stop_at ( struct profiler *profiler, unsigned long stopped ) {
|
86
|
101
|
|
87
|
102
|
/* If profiling is active then record end timestamp and update stats */
|
88
|
103
|
if ( PROFILING ) {
|
89
|
|
- ended = profile_timestamp();
|
90
|
|
- profile_update ( profiler, ( ended - profiler->started ) );
|
|
104
|
+ profiler->stopped = stopped;
|
|
105
|
+ profile_update ( profiler, ( stopped - profiler->started ) );
|
91
|
106
|
}
|
92
|
107
|
}
|
93
|
108
|
|
|
109
|
+/**
|
|
110
|
+ * Record profiling result
|
|
111
|
+ *
|
|
112
|
+ * @v profiler Profiler
|
|
113
|
+ */
|
|
114
|
+static inline __attribute__ (( always_inline )) void
|
|
115
|
+profile_stop ( struct profiler *profiler ) {
|
|
116
|
+
|
|
117
|
+ /* If profiling is active then record end timestamp and update stats */
|
|
118
|
+ if ( PROFILING )
|
|
119
|
+ profile_stop_at ( profiler, profile_timestamp() );
|
|
120
|
+}
|
|
121
|
+
|
94
|
122
|
#endif /* _IPXE_PROFILE_H */
|