59 unsigned int shift ) {
60 static char buf[23] =
"-";
61 unsigned long long int_part;
71 int_part = (
value >> shift );
72 frac_part = (
value >> ( shift - ( 8 *
sizeof ( frac_part ) ) ) );
73 snprintf ( &buf[1], (
sizeof ( buf ) - 1 ),
"%#llx.%02x",
74 int_part, frac_part );
111 unsigned int sample_msb;
112 unsigned int mean_shift;
113 unsigned int delta_shift;
114 signed long pre_delta;
115 signed long post_delta;
116 signed long long accvar_delta;
117 unsigned int accvar_delta_shift;
118 unsigned int accvar_delta_msb;
119 unsigned int accvar_shift;
124 assert ( ( (
signed ) sample ) >= 0 );
136 sample_msb = (
flsl ( sample ) - 1 );
145 sample <<= mean_shift;
151 delta_shift = mean_shift;
153 ( sample >> mean_shift ),
166 if (
sizeof ( pre_delta ) > (
sizeof ( accvar_delta ) / 2 ) ) {
167 unsigned int shift = ( 8 * (
sizeof ( pre_delta ) -
168 (
sizeof ( accvar_delta ) / 2 ) ));
170 post_delta >>= shift;
171 delta_shift -= shift;
179 if ( pre_delta && post_delta ) {
182 accvar_delta = ( ( (
signed long long ) pre_delta ) *
183 ( (
signed long long ) post_delta ) );
184 accvar_delta_shift = ( 2 * delta_shift );
185 assert ( accvar_delta > 0 );
191 accvar_delta_msb = (
flsll ( accvar_delta ) - 1 );
192 if ( accvar_delta_msb > accvar_delta_shift ) {
193 accvar_delta_msb -= accvar_delta_shift;
195 accvar_delta_msb = 0;
214 accvar_delta <<= ( accvar_shift - accvar_delta_shift );
245 return ( (
profiler->
mean + ( 1UL << ( mean_shift - 1 ) ) )
266 + ( 1ULL << ( accvar_shift - 1 ) ) ) >> accvar_shift );
unsigned long profile_mean(struct profiler *profiler)
Get mean sample value.
static unsigned int profile_mean_shift(struct profiler *profiler)
Calculate bit shift for mean sample value.
unsigned long isqrt(unsigned long value)
Find integer square root.
unsigned long long accvar
Accumulated variance (scaled)
#define flsll(x)
Find last (i.e.
A data structure for storing profiling information.
unsigned long profile_stddev(struct profiler *profiler)
Get sample standard deviation.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
unsigned int mean_msb
Mean sample value MSB.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
unsigned int count
Number of samples.
pseudo_bit_t value[0x00020]
unsigned long profile_variance(struct profiler *profiler)
Get sample variance.
void profile_update(struct profiler *profiler, unsigned long sample)
Update profiler with a new sample.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
unsigned long profile_excluded
Accumulated time excluded from profiling.
#define flsl(x)
Find last (i.e.
unsigned int accvar_msb
Accumulated variance MSB.
unsigned long mean
Mean sample value (scaled)
static const char * profile_hex_fraction(signed long long value, unsigned int shift)
Format a hex fraction (for debugging)
static unsigned int profile_accvar_shift(struct profiler *profiler)
Calculate bit shift for accumulated variance value.