mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-31 11:59:36 -05:00
quartile prints.
git-svn-id: file:///svn/unbound/trunk@833 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
a67e62dd40
commit
f1a3c9b646
3 changed files with 54 additions and 0 deletions
|
|
@ -2,6 +2,9 @@
|
|||
- fixup openssl RAND problem, when the system is not configured to
|
||||
give entropy, and the rng needs to be seeded.
|
||||
|
||||
8 January 2008: Wouter
|
||||
- print median and quartiles with extensive logging.
|
||||
|
||||
4 January 2008: Wouter
|
||||
- document misconfiguration in private network.
|
||||
|
||||
|
|
|
|||
|
|
@ -153,6 +153,10 @@ void timehist_log(struct timehist* hist)
|
|||
{
|
||||
#ifndef S_SPLINT_S
|
||||
size_t i;
|
||||
log_info("[25%%]=%g median[50%%]=%g [75%%]=%g",
|
||||
timehist_quartile(hist, 0.25),
|
||||
timehist_quartile(hist, 0.50),
|
||||
timehist_quartile(hist, 0.75));
|
||||
/* 0000.000000 0000.000000 0 */
|
||||
log_info("lower(secs) upper(secs) replycount");
|
||||
for(i=0; i<hist->num; i++) {
|
||||
|
|
@ -167,3 +171,40 @@ void timehist_log(struct timehist* hist)
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/** total number in histogram */
|
||||
size_t
|
||||
timehist_count(struct timehist* hist)
|
||||
{
|
||||
size_t i, res = 0;
|
||||
for(i=0; i<hist->num; i++)
|
||||
res += hist->buckets[i].count;
|
||||
return res;
|
||||
}
|
||||
|
||||
double
|
||||
timehist_quartile(struct timehist* hist, double q)
|
||||
{
|
||||
double lookfor, passed, res;
|
||||
double low = 0, up = 0;
|
||||
size_t i;
|
||||
if(!hist || hist->num == 0)
|
||||
return 0.;
|
||||
/* look for i'th element, interpolated */
|
||||
lookfor = (double)timehist_count(hist) * q;
|
||||
passed = 0;
|
||||
i = 0;
|
||||
while(i+1 < hist->num &&
|
||||
passed+(double)hist->buckets[i].count < lookfor) {
|
||||
passed += (double)hist->buckets[i++].count;
|
||||
}
|
||||
/* got the right bucket */
|
||||
#ifndef S_SPLINT_S
|
||||
low = (double)hist->buckets[i].lower.tv_sec +
|
||||
(double)hist->buckets[i].lower.tv_usec/1000000.;
|
||||
up = (double)hist->buckets[i].upper.tv_sec +
|
||||
(double)hist->buckets[i].upper.tv_usec/1000000.;
|
||||
#endif
|
||||
res = (lookfor - passed)*(up-low)/((double)hist->buckets[i].count);
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,16 @@ void timehist_delete(struct timehist* hist);
|
|||
*/
|
||||
void timehist_insert(struct timehist* hist, struct timeval* tv);
|
||||
|
||||
/**
|
||||
* Find time value for given quartile, such as 0.25, 0.50, 0.75.
|
||||
* The looks up the value for the i-th element in the sorted list of time
|
||||
* values, as approximated using the histogram.
|
||||
* @param hist: histogram. Interpolated information is used from it.
|
||||
* @param q: quartile, 0.50 results in the median. Must be >0 and <1.
|
||||
* @return: the time in seconds for that percentage.
|
||||
*/
|
||||
double timehist_quartile(struct timehist* hist, double q);
|
||||
|
||||
/**
|
||||
* Printout histogram
|
||||
* @param hist: histogram
|
||||
|
|
|
|||
Loading…
Reference in a new issue