60 unsigned int shift ) {
61 static char buf[23] =
"-";
62 unsigned long long int_part;
72 int_part = (
value >> shift );
73 frac_part = (
value >> ( shift - ( 8 *
sizeof ( frac_part ) ) ) );
74 snprintf ( &buf[1], (
sizeof ( buf ) - 1 ),
"%#llx.%02x",
75 int_part, frac_part );
112 unsigned int sample_msb;
113 unsigned int mean_shift;
114 unsigned int delta_shift;
115 signed long pre_delta;
116 signed long post_delta;
117 signed long long accvar_delta;
118 unsigned int accvar_delta_shift;
119 unsigned int accvar_delta_msb;
120 unsigned int accvar_shift;
125 assert ( ( (
signed ) sample ) >= 0 );
137 sample_msb = (
flsl ( sample ) - 1 );
146 sample <<= mean_shift;
152 delta_shift = mean_shift;
154 ( sample >> mean_shift ),
167 if (
sizeof ( pre_delta ) > (
sizeof ( accvar_delta ) / 2 ) ) {
168 unsigned int shift = ( 8 * (
sizeof ( pre_delta ) -
169 (
sizeof ( accvar_delta ) / 2 ) ));
171 post_delta >>= shift;
172 delta_shift -= shift;
180 if ( pre_delta && post_delta ) {
183 accvar_delta = ( ( (
signed long long ) pre_delta ) *
184 ( (
signed long long ) post_delta ) );
185 accvar_delta_shift = ( 2 * delta_shift );
186 assert ( accvar_delta > 0 );
192 accvar_delta_msb = (
flsll ( accvar_delta ) - 1 );
193 if ( accvar_delta_msb > accvar_delta_shift ) {
194 accvar_delta_msb -= accvar_delta_shift;
196 accvar_delta_msb = 0;
215 accvar_delta <<= ( accvar_shift - accvar_delta_shift );
246 return ( (
profiler->
mean + ( 1UL << ( mean_shift - 1 ) ) )
267 + ( 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.