Experimental subsampling API
From NetLogger
Contents |
Overview
Defines
#define NL_MAX_SMPL 16 #define NL_write_begin(I, L, V, E, F, args...) #define NL_write_end(I, L, V, E, F, args...)
Functions
void NL_set_smpl_rate (NL_log_T, double prob_true) NL_smpl_t NL_get_smpl (NL_log_T self)
Detailed Description
This only works with pairs of events in the same static scope (function).
Define Documentation
#define NL_MAX_SMPL 16
Maximum number of things to sample
#define NL_write_begin (I,L,V,E,F,args ...)
- Value:
do {
NL_smpl_t smpl = NL_get_smpl(L);
if ((unsigned long)random() <= smpl->rate &&
smpl->id_len < NL_MAX_SMPL) {
smpl->id_list[smpl->id_len++] = (I);
NL_write((L),(V),(E),(F), ##args);
}
} while(0)
- Begin of a sampled begin/end event pair.
#define NL_write_end (I,l,V,E,F,args...)
- Value:
do {
int i;
NL_smpl_t smpl = NL_get_smpl(L);
for (i=0; i < smpl->id_len; i++ ) {
if ( smpl->id_list[i] == (I) ) {
int j;
NL_write((L),(V),(E),(F),##args);
for (j=i+1; j < smpl->id_len; j++)
smpl->id_list[j-1] = smpl->id_list[j];
smpl->id_len--;
break;
}
}
} while(0)
End of sampled begin/end event pair.
Function Documentation
NL_smpl_t NL_get_smpl (NL_log_T self)
- Get current sampling obj.
- Parameters: self Log object to sample
void NL_set_smpl_rate (NL_log_T, double prob_true)
- Set sampling rate for (experimental) sub-sampling API
- Parameters: prob_true Probability 0..1 of a given event being sampled
