iPXE
|
Profiling. More...
#include <stdint.h>
#include <stdio.h>
#include <strings.h>
#include <limits.h>
#include <assert.h>
#include <ipxe/isqrt.h>
#include <ipxe/profile.h>
Go to the source code of this file.
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static const char * | profile_hex_fraction (signed long long value, unsigned int shift) |
Format a hex fraction (for debugging) More... | |
static unsigned int | profile_mean_shift (struct profiler *profiler) |
Calculate bit shift for mean sample value. More... | |
static unsigned int | profile_accvar_shift (struct profiler *profiler) |
Calculate bit shift for accumulated variance value. More... | |
void | profile_update (struct profiler *profiler, unsigned long sample) |
Update profiler with a new sample. More... | |
unsigned long | profile_mean (struct profiler *profiler) |
Get mean sample value. More... | |
unsigned long | profile_variance (struct profiler *profiler) |
Get sample variance. More... | |
unsigned long | profile_stddev (struct profiler *profiler) |
Get sample standard deviation. More... | |
Variables | |
unsigned long | profile_excluded |
Accumulated time excluded from profiling. More... | |
Profiling.
The profiler computes basic statistics (mean, variance, and standard deviation) for the samples which it records. Note that these statistics need not be completely accurate; it is sufficient to give a rough approximation.
The algorithm for updating the mean and variance estimators is from The Art of Computer Programming (via Wikipedia), with adjustments to avoid the use of floating-point instructions.
Definition in file profile.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Format a hex fraction (for debugging)
value | Value |
shift | Bit shift |
string | Formatted hex fraction |
Definition at line 58 of file profile.c.
References snprintf(), and value.
Referenced by profile_update().
|
inlinestatic |
Calculate bit shift for mean sample value.
profiler | Profiler |
shift | Bit shift |
Definition at line 84 of file profile.c.
References profiler::mean, and profiler::mean_msb.
Referenced by profile_mean(), and profile_update().
|
inlinestatic |
Calculate bit shift for accumulated variance value.
profiler | Profiler |
shift | Bit shift |
Definition at line 97 of file profile.c.
References profiler::accvar, and profiler::accvar_msb.
Referenced by profile_update(), and profile_variance().
void profile_update | ( | struct profiler * | profiler, |
unsigned long | sample | ||
) |
Update profiler with a new sample.
profiler | Profiler |
sample | Sample value |
Definition at line 110 of file profile.c.
References profiler::accvar, profiler::accvar_msb, assert(), profiler::count, DBGC, flsl, flsll, INT_MAX, profiler::mean, profiler::mean_msb, profile_accvar_shift(), profile_hex_fraction(), and profile_mean_shift().
Referenced by profile_custom(), profile_okx(), and profile_stop_at().
unsigned long profile_mean | ( | struct profiler * | profiler | ) |
Get mean sample value.
profiler | Profiler |
mean | Mean sample value |
Definition at line 241 of file profile.c.
References profiler::mean, and profile_mean_shift().
Referenced by cipher_cost(), digest_cost(), memcpy_test_speed(), profile_okx(), profstat(), and tcpip_random_okx().
unsigned long profile_variance | ( | struct profiler * | profiler | ) |
Get sample variance.
profiler | Profiler |
variance | Sample variance |
Definition at line 255 of file profile.c.
References profiler::accvar, profiler::count, and profile_accvar_shift().
Referenced by profile_stddev().
unsigned long profile_stddev | ( | struct profiler * | profiler | ) |
Get sample standard deviation.
profiler | Profiler |
stddev | Sample standard deviation |
Definition at line 275 of file profile.c.
References isqrt(), and profile_variance().
Referenced by memcpy_test_speed(), profile_okx(), profstat(), and tcpip_random_okx().
unsigned long profile_excluded |
Accumulated time excluded from profiling.
Definition at line 49 of file profile.c.
Referenced by profile_exclude(), profile_start_at(), profile_started(), profile_stop_at(), and profile_stopped().