Lines Matching refs:hist
72 dosetup(struct timehist* hist) in dosetup() argument
77 for(i=0; i<hist->num; i++) { in dosetup()
78 hist->buckets[i].lower = last; in dosetup()
80 hist->buckets[i].upper = last; in dosetup()
81 hist->buckets[i].count = 0; in dosetup()
87 struct timehist* hist = (struct timehist*)calloc(1, in timehist_setup() local
89 if(!hist) in timehist_setup()
91 hist->num = NUM_BUCKETS_HIST; in timehist_setup()
92 hist->buckets = (struct th_buck*)calloc(hist->num, in timehist_setup()
94 if(!hist->buckets) { in timehist_setup()
95 free(hist); in timehist_setup()
99 dosetup(hist); in timehist_setup()
100 return hist; in timehist_setup()
103 void timehist_delete(struct timehist* hist) in timehist_delete() argument
105 if(!hist) in timehist_delete()
107 free(hist->buckets); in timehist_delete()
108 free(hist); in timehist_delete()
111 void timehist_clear(struct timehist* hist) in timehist_clear() argument
114 for(i=0; i<hist->num; i++) in timehist_clear()
115 hist->buckets[i].count = 0; in timehist_clear()
118 void timehist_insert(struct timehist* hist, struct timeval* tv) in timehist_insert() argument
121 for(i=0; i<hist->num; i++) { in timehist_insert()
122 if(timeval_smaller(tv, &hist->buckets[i].upper)) { in timehist_insert()
123 hist->buckets[i].count++; in timehist_insert()
128 hist->buckets[hist->num-1].count++; in timehist_insert()
131 void timehist_print(struct timehist* hist) in timehist_print() argument
135 for(i=0; i<hist->num; i++) { in timehist_print()
136 if(hist->buckets[i].count != 0) { in timehist_print()
138 (int)hist->buckets[i].lower.tv_sec, in timehist_print()
139 (int)hist->buckets[i].lower.tv_usec, in timehist_print()
140 (int)hist->buckets[i].upper.tv_sec, in timehist_print()
141 (int)hist->buckets[i].upper.tv_usec, in timehist_print()
142 (unsigned)hist->buckets[i].count); in timehist_print()
148 void timehist_log(struct timehist* hist, const char* name) in timehist_log() argument
153 timehist_quartile(hist, 0.25), in timehist_log()
154 timehist_quartile(hist, 0.50), in timehist_log()
155 timehist_quartile(hist, 0.75)); in timehist_log()
158 for(i=0; i<hist->num; i++) { in timehist_log()
159 if(hist->buckets[i].count != 0) { in timehist_log()
161 (int)hist->buckets[i].lower.tv_sec, in timehist_log()
162 (int)hist->buckets[i].lower.tv_usec, in timehist_log()
163 (int)hist->buckets[i].upper.tv_sec, in timehist_log()
164 (int)hist->buckets[i].upper.tv_usec, in timehist_log()
165 (unsigned)hist->buckets[i].count); in timehist_log()
173 timehist_count(struct timehist* hist) in timehist_count() argument
176 for(i=0; i<hist->num; i++) in timehist_count()
177 res += hist->buckets[i].count; in timehist_count()
182 timehist_quartile(struct timehist* hist, double q) in timehist_quartile() argument
187 if(!hist || hist->num == 0) in timehist_quartile()
190 lookfor = (double)timehist_count(hist); in timehist_quartile()
196 while(i+1 < hist->num && in timehist_quartile()
197 passed+(double)hist->buckets[i].count < lookfor) { in timehist_quartile()
198 passed += (double)hist->buckets[i++].count; in timehist_quartile()
202 low = (double)hist->buckets[i].lower.tv_sec + in timehist_quartile()
203 (double)hist->buckets[i].lower.tv_usec/1000000.; in timehist_quartile()
204 up = (double)hist->buckets[i].upper.tv_sec + in timehist_quartile()
205 (double)hist->buckets[i].upper.tv_usec/1000000.; in timehist_quartile()
207 res = (lookfor - passed)*(up-low)/((double)hist->buckets[i].count); in timehist_quartile()
212 timehist_export(struct timehist* hist, long long* array, size_t sz) in timehist_export() argument
215 if(!hist) return; in timehist_export()
216 if(sz > hist->num) in timehist_export()
217 sz = hist->num; in timehist_export()
219 array[i] = (long long)hist->buckets[i].count; in timehist_export()
223 timehist_import(struct timehist* hist, long long* array, size_t sz) in timehist_import() argument
226 if(!hist) return; in timehist_import()
227 if(sz > hist->num) in timehist_import()
228 sz = hist->num; in timehist_import()
230 hist->buckets[i].count = (size_t)array[i]; in timehist_import()