- 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.
{
#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++) {
}
#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;
+}
*/
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