Lines Matching refs:sip
100 static void sps_emit(struct seeki *sip) in sps_emit() argument
103 struct sps_bkt *sps = &sip->sps; in sps_emit()
115 fprintf(sip->sps_fp, "%15.9lf %.2lf\n", sps->t_start, s_p_s); in sps_emit()
121 static void sps_add(struct seeki *sip, double t) in sps_add() argument
123 if (sip->sps_fp) { in sps_add()
124 struct sps_bkt *sps = &sip->sps; in sps_add()
127 sps_emit(sip); in sps_add()
184 long long seek_dist(struct seeki *sip, struct io *iop) in seek_dist() argument
190 dist = start - sip->last_end; in seek_dist()
193 if (((sip->last_start <= start) && (start <= sip->last_end)) || in seek_dist()
194 ((sip->last_start <= end) && (end <= sip->last_end))) in seek_dist()
196 else if (start > sip->last_end) in seek_dist()
197 dist = start - sip->last_end; in seek_dist()
199 dist = start - sip->last_start; in seek_dist()
203 sip->last_start = start; in seek_dist()
204 sip->last_end = end; in seek_dist()
210 struct seeki *sip = malloc(sizeof(struct seeki)); in seeki_alloc() local
212 sip->rfp = seek_open(str, 'r'); in seeki_alloc()
213 sip->wfp = seek_open(str, 'w'); in seeki_alloc()
214 sip->cfp = seek_open(str, 'c'); in seeki_alloc()
215 sip->tot_seeks = 0; in seeki_alloc()
216 sip->total_sectors = 0.0; in seeki_alloc()
217 sip->last_start = sip->last_end = 0; in seeki_alloc()
218 memset(&sip->root, 0, sizeof(sip->root)); in seeki_alloc()
223 memset(&sip->sps, 0, sizeof(sip->sps)); in seeki_alloc()
227 if ((sip->sps_fp = my_fopen(oname, "w")) == NULL) in seeki_alloc()
230 add_file(sip->sps_fp, oname); in seeki_alloc()
232 sip->sps_fp = NULL; in seeki_alloc()
234 return sip; in seeki_alloc()
239 struct seeki *sip = param; in seeki_free() local
241 if (sip->sps_fp && sip->sps.nseeks != 0) in seeki_free()
242 sps_emit(sip); in seeki_free()
247 __destroy(sip->root.rb_node); in seeki_free()
248 free(sip); in seeki_free()
253 struct seeki *sip = handle; in seeki_add() local
255 long long dist = seek_dist(sip, iop); in seeki_add()
257 FILE *fp = IOP_READ(iop) ? sip->rfp : sip->wfp; in seeki_add()
261 if (sip->cfp) in seeki_add()
262 fprintf(sip->cfp, "%15.9lf %13lld %c\n", tstamp, dist, rw); in seeki_add()
265 sip->tot_seeks++; in seeki_add()
266 sip->total_sectors += dist; in seeki_add()
267 __insert(&sip->root, dist); in seeki_add()
269 sps_add(sip, tstamp); in seeki_add()
279 struct seeki *sip = handle; in seeki_mean() local
280 return sip->total_sectors / sip->tot_seeks; in seeki_mean()
286 struct seeki *sip = handle; in seeki_median() local
288 if (sip->root.rb_node) in seeki_median()
289 (void)__median(sip->root.rb_node, 0LL, sip->tot_seeks / 2, in seeki_median()
297 struct seeki *sip = handle; in seeki_mode() local
298 struct rb_root *root = &sip->root; in seeki_mode()