3 # module to parse fio histogram log files, not using pandas
4 # runs in python v2 or v3
5 # to get help with the CLI: $ python fio-histo-log-pctiles.py -h
6 # this can be run standalone as a script but is callable
7 # assumes all threads run for same time duration
8 # assumes all threads are doing the same thing for the entire run
16 # separate read and write stats for randrw mixed workload
17 # report average latency if needed
18 # prove that it works (partially done with unit tests)
20 # to run unit tests, set UNITTEST environment variable to anything
21 # if you do this, don't pass normal CLI parameters to it
22 # otherwise it runs the CLI
24 import sys, os, math, copy
25 from copy import deepcopy
32 class FioHistoLogExc(Exception):
35 # if there is an error, print message, and exit with error status
38 print('ERROR: ' + msg)
41 # convert histogram log file into a list of
42 # (time_ms, direction, bsz, buckets) tuples where
43 # - time_ms is the time in msec at which the log record was written
44 # - direction is 0 (read) or 1 (write)
45 # - bsz is block size (not used)
46 # - buckets is a CSV list of counters that make up the histogram
47 # caller decides if the expected number of counters are present
50 def exception_suffix( record_num, pathname ):
51 return 'in histogram record %d file %s' % (record_num+1, pathname)
53 # log file parser raises FioHistoLogExc exceptions
54 # it returns histogram buckets in whatever unit fio uses
56 def parse_hist_file(logfn, buckets_per_interval):
57 max_timestamp_ms = 0.0
59 with open(logfn, 'r') as f:
60 records = [ l.strip() for l in f.readlines() ]
64 for k, r in enumerate(records):
69 int_tokens = [ int(t) for t in tokens ]
70 except ValueError as e:
71 raise FioHistoLogExc('non-integer value %s' % exception_suffix(k+1, logfn))
73 neg_ints = list(filter( lambda tk : tk < 0, int_tokens ))
75 raise FioHistoLogExc('negative integer value %s' % exception_suffix(k+1, logfn))
77 if len(int_tokens) < 3:
78 raise FioHistoLogExc('too few numbers %s' % exception_suffix(k+1, logfn))
80 time_ms = int_tokens[0]
81 if time_ms > max_timestamp_ms:
82 max_timestamp_ms = time_ms
84 direction = int_tokens[1]
85 if direction != 0 and direction != 1:
86 raise FioHistoLogExc('invalid I/O direction %s' % exception_suffix(k+1, logfn))
90 raise FioHistoLogExc('block size too large %s' % exception_suffix(k+1, logfn))
92 buckets = int_tokens[3:]
93 if len(buckets) != buckets_per_interval:
94 raise FioHistoLogExc('%d buckets per interval but %d expected in %s' %
95 (len(buckets), buckets_per_interval, exception_suffix(k+1, logfn)))
97 # hack to filter out records with the same timestamp
98 # we should not have to do this if fio logs histogram records correctly
100 if time_ms == last_time_ms and direction == last_direction:
102 last_time_ms = time_ms
103 last_direction = direction
105 intervals.append((time_ms, direction, bsz, buckets))
106 if len(intervals) == 0:
107 raise FioHistoLogExc('no records in %s' % logfn)
108 return (intervals, max_timestamp_ms)
111 # compute time range for each bucket index in histogram record
112 # see comments in https://github.com/axboe/fio/blob/master/stat.h
113 # for description of bucket groups and buckets
114 # fio v3 bucket ranges are in nanosec (since response times are measured in nanosec)
115 # but we convert fio v3 nanosecs to floating-point microseconds
117 def time_ranges(groups, counters_per_group, fio_version=3):
120 bucket_intervals = []
121 for g in range(0, groups):
122 for b in range(0, counters_per_group):
123 rmin = float(bucket_base)
124 rmax = rmin + bucket_width
126 rmin /= nsec_per_usec
127 rmax /= nsec_per_usec
128 bucket_intervals.append( [rmin, rmax] )
129 bucket_base += bucket_width
132 return bucket_intervals
135 # compute number of time quantum intervals in the test
137 def get_time_intervals(time_quantum, max_timestamp_ms):
138 # round down to nearest second
139 max_timestamp = max_timestamp_ms // msec_per_sec
140 # round up to nearest whole multiple of time_quantum
141 time_interval_count = (max_timestamp + time_quantum) // time_quantum
142 end_time = time_interval_count * time_quantum
143 return (end_time, time_interval_count)
145 # align raw histogram log data to time quantum so
146 # we can then combine histograms from different threads with addition
147 # for randrw workload we count both reads and writes in same output bucket
148 # but we separate reads and writes for purposes of calculating
149 # end time for histogram record.
150 # this requires us to weight a raw histogram bucket by the
151 # fraction of time quantum that the bucket overlaps the current
152 # time quantum interval
153 # for example, if we have a bucket with 515 samples for time interval
154 # [ 1010, 2014 ] msec since start of test, and time quantum is 1 sec, then
155 # for time quantum interval [ 1000, 2000 ] msec, the overlap is
156 # (2000 - 1010) / (2000 - 1000) = 0.99
157 # so the contribution of this bucket to this time quantum is
158 # 515 x 0.99 = 509.85
160 def align_histo_log(raw_histogram_log, time_quantum, bucket_count, max_timestamp_ms):
162 # slice up test time int intervals of time_quantum seconds
164 (end_time, time_interval_count) = get_time_intervals(time_quantum, max_timestamp_ms)
165 time_qtm_ms = time_quantum * msec_per_sec
166 end_time_ms = end_time * msec_per_sec
167 aligned_intervals = []
168 for j in range(0, time_interval_count):
169 aligned_intervals.append((
171 [ 0.0 for j in range(0, bucket_count) ] ))
173 log_record_count = len(raw_histogram_log)
174 for k, record in enumerate(raw_histogram_log):
176 # find next record with same direction to get end-time
177 # have to avoid going past end of array
178 # for fio randrw workload,
179 # we have read and write records on same time interval
180 # sometimes read and write records are in opposite order
181 # assertion checks that next read/write record
182 # can be separated by at most 2 other records
184 (time_msec, direction, sz, interval_buckets) = record
185 if k+1 < log_record_count:
186 (time_msec_end, direction2, _, _) = raw_histogram_log[k+1]
187 if direction2 != direction:
188 if k+2 < log_record_count:
189 (time_msec_end, direction2, _, _) = raw_histogram_log[k+2]
190 if direction2 != direction:
191 if k+3 < log_record_count:
192 (time_msec_end, direction2, _, _) = raw_histogram_log[k+3]
193 assert direction2 == direction
195 time_msec_end = end_time_ms
197 time_msec_end = end_time_ms
199 time_msec_end = end_time_ms
201 # calculate first quantum that overlaps this histogram record
203 qtm_start_ms = (time_msec // time_qtm_ms) * time_qtm_ms
204 qtm_end_ms = ((time_msec + time_qtm_ms) // time_qtm_ms) * time_qtm_ms
205 qtm_index = qtm_start_ms // time_qtm_ms
207 # for each quantum that overlaps this histogram record's time interval
209 while qtm_start_ms < time_msec_end: # while quantum overlaps record
211 # calculate fraction of time that this quantum
212 # overlaps histogram record's time interval
214 overlap_start = max(qtm_start_ms, time_msec)
215 overlap_end = min(qtm_end_ms, time_msec_end)
216 weight = float(overlap_end - overlap_start)
217 weight /= (time_msec_end - time_msec)
218 (_,aligned_histogram) = aligned_intervals[qtm_index]
219 for bx, b in enumerate(interval_buckets):
220 weighted_bucket = weight * b
221 aligned_histogram[bx] += weighted_bucket
223 # advance to the next time quantum
225 qtm_start_ms += time_qtm_ms
226 qtm_end_ms += time_qtm_ms
229 return aligned_intervals
231 # add histogram in "source" to histogram in "target"
232 # it is assumed that the 2 histograms are precisely time-aligned
234 def add_to_histo_from( target, source ):
235 for b in range(0, len(source)):
236 target[b] += source[b]
238 # compute percentiles
240 # buckets: histogram bucket array
241 # wanted: list of floating-pt percentiles to calculate
242 # time_ranges: [tmin,tmax) time interval for each bucket
243 # returns None if no I/O reported.
244 # otherwise we would be dividing by zero
245 # think of buckets as probability distribution function
246 # and this loop is integrating to get cumulative distribution function
248 def get_pctiles(buckets, wanted, time_ranges):
250 # get total of IO requests done
252 for io_count in buckets:
253 total_ios += io_count
255 # don't return percentiles if no I/O was done during interval
259 pctile_count = len(wanted)
261 # results returned as dictionary keyed by percentile
264 # index of next percentile in list
268 next_pctile = wanted[pctile_index]
270 # no one is interested in percentiles bigger than this but not 100.0
271 # this prevents floating-point error from preventing loop exit
274 # pct is the percentile corresponding to
275 # all I/O requests up through bucket b
278 for b, io_count in enumerate(buckets):
281 total_so_far += io_count
282 # last_pct_lt is the percentile corresponding to
283 # all I/O requests up to, but not including, bucket b
285 pct = 100.0 * float(total_so_far) / total_ios
286 # a single bucket could satisfy multiple pctiles
287 # so this must be a while loop
288 # for 100-percentile (max latency) case, no bucket exceeds it
289 # so we must stop there.
290 while ((next_pctile == 100.0 and pct >= almost_100) or
291 (next_pctile < 100.0 and pct > next_pctile)):
292 # interpolate between min and max time for bucket time interval
293 # we keep the time_ranges access inside this loop,
294 # even though it could be above the loop,
295 # because in many cases we will not be even entering
296 # the loop so we optimize out these accesses
297 range_max_time = time_ranges[b][1]
298 range_min_time = time_ranges[b][0]
299 offset_frac = (next_pctile - last_pct)/(pct - last_pct)
300 interpolation = range_min_time + (offset_frac*(range_max_time - range_min_time))
301 pctile_result[next_pctile] = interpolation
303 if pctile_index == pctile_count:
305 next_pctile = wanted[pctile_index]
306 if pctile_index == pctile_count:
308 assert pctile_index == pctile_count
312 # this is really the main program
314 def compute_percentiles_from_logs():
315 parser = argparse.ArgumentParser()
316 parser.add_argument("--fio-version", dest="fio_version",
317 default="3", choices=[2,3], type=int,
318 help="fio version (default=3)")
319 parser.add_argument("--bucket-groups", dest="bucket_groups", default="29", type=int,
320 help="fio histogram bucket groups (default=29)")
321 parser.add_argument("--bucket-bits", dest="bucket_bits",
322 default="6", type=int,
323 help="fio histogram buckets-per-group bits (default=6 means 64 buckets/group)")
324 parser.add_argument("--percentiles", dest="pctiles_wanted",
325 default=[ 0., 50., 95., 99., 100.], type=float, nargs='+',
326 help="fio histogram buckets-per-group bits (default=6 means 64 buckets/group)")
327 parser.add_argument("--time-quantum", dest="time_quantum",
328 default="1", type=int,
329 help="time quantum in seconds (default=1)")
330 parser.add_argument("--output-unit", dest="output_unit",
331 default="usec", type=str,
332 help="Latency percentile output unit: msec|usec|nsec (default usec)")
333 parser.add_argument("file_list", nargs='+',
334 help='list of files, preceded by " -- " if necessary')
335 args = parser.parse_args()
337 # default changes based on fio version
338 if args.fio_version == 2:
339 args.bucket_groups = 19
343 print('fio version = %d' % args.fio_version)
344 print('bucket groups = %d' % args.bucket_groups)
345 print('bucket bits = %d' % args.bucket_bits)
346 print('time quantum = %d sec' % args.time_quantum)
347 print('percentiles = %s' % ','.join([ str(p) for p in args.pctiles_wanted ]))
348 buckets_per_group = 1 << args.bucket_bits
349 print('buckets per group = %d' % buckets_per_group)
350 buckets_per_interval = buckets_per_group * args.bucket_groups
351 print('buckets per interval = %d ' % buckets_per_interval)
352 bucket_index_range = range(0, buckets_per_interval)
353 if args.time_quantum == 0:
354 print('ERROR: time-quantum must be a positive number of seconds')
355 print('output unit = ' + args.output_unit)
356 if args.output_unit == 'msec':
357 time_divisor = 1000.0
358 elif args.output_unit == 'usec':
361 # calculate response time interval associated with each histogram bucket
363 bucket_times = time_ranges(args.bucket_groups, buckets_per_group, fio_version=args.fio_version)
365 # construct template for each histogram bucket array with buckets all zeroes
366 # we just copy this for each new histogram
368 zeroed_buckets = [ 0.0 for r in bucket_index_range ]
370 # print CSV header just like fiologparser_hist does
373 for p in args.pctiles_wanted:
374 header += '%3.1f, ' % p
375 print('time (millisec), percentiles in increasing order with values in ' + args.output_unit)
378 # parse the histogram logs
379 # assumption: each bucket has a monotonically increasing time
380 # assumption: time ranges do not overlap for a single thread's records
381 # (exception: if randrw workload, then there is a read and a write
382 # record for the same time interval)
384 max_timestamp_all_logs = 0
386 for fn in args.file_list:
388 (hist_files[fn], max_timestamp_ms) = parse_hist_file(fn, buckets_per_interval)
389 except FioHistoLogExc as e:
391 max_timestamp_all_logs = max(max_timestamp_all_logs, max_timestamp_ms)
393 (end_time, time_interval_count) = get_time_intervals(args.time_quantum, max_timestamp_all_logs)
394 all_threads_histograms = [ ((j*args.time_quantum*msec_per_sec), deepcopy(zeroed_buckets))
395 for j in range(0, time_interval_count) ]
397 for logfn in hist_files.keys():
398 aligned_per_thread = align_histo_log(hist_files[logfn],
400 buckets_per_interval,
401 max_timestamp_all_logs)
402 for t in range(0, time_interval_count):
403 (_, all_threads_histo_t) = all_threads_histograms[t]
404 (_, log_histo_t) = aligned_per_thread[t]
405 add_to_histo_from( all_threads_histo_t, log_histo_t )
407 # calculate percentiles across aggregate histogram for all threads
409 for (t_msec, all_threads_histo_t) in all_threads_histograms:
410 record = '%d, ' % t_msec
411 pct = get_pctiles(all_threads_histo_t, args.pctiles_wanted, bucket_times)
413 for w in args.pctiles_wanted:
416 pct_keys = [ k for k in pct.keys() ]
417 pct_values = [ str(pct[wanted]/time_divisor) for wanted in sorted(pct_keys) ]
418 record += ', '.join(pct_values)
427 ##### below are unit tests ##############
429 import tempfile, shutil
430 from os.path import join
431 should_not_get_here = False
433 class Test(unittest2.TestCase):
436 # a little less typing please
437 def A(self, boolean_val):
438 self.assertTrue(boolean_val)
440 # initialize unit test environment
444 d = tempfile.mkdtemp()
447 # remove anything left by unit test environment
448 # unless user sets UNITTEST_LEAVE_FILES environment variable
451 def tearDownClass(cls):
452 if not os.getenv("UNITTEST_LEAVE_FILES"):
453 shutil.rmtree(cls.tempdir)
456 self.fn = join(Test.tempdir, self.id())
458 def test_a_add_histos(self):
461 add_to_histo_from( a, b )
462 self.A(a == [2.5, 4.5])
463 self.A(b == [1.5, 2.5])
465 def test_b1_parse_log(self):
466 with open(self.fn, 'w') as f:
467 f.write('1234, 0, 4096, 1, 2, 3, 4\n')
468 f.write('5678,1,16384,5,6,7,8 \n')
469 (raw_histo_log, max_timestamp) = parse_hist_file(self.fn, 4) # 4 buckets per interval
470 self.A(len(raw_histo_log) == 2 and max_timestamp == 5678)
471 (time_ms, direction, bsz, histo) = raw_histo_log[0]
472 self.A(time_ms == 1234 and direction == 0 and bsz == 4096 and histo == [ 1, 2, 3, 4 ])
473 (time_ms, direction, bsz, histo) = raw_histo_log[1]
474 self.A(time_ms == 5678 and direction == 1 and bsz == 16384 and histo == [ 5, 6, 7, 8 ])
476 def test_b2_parse_empty_log(self):
477 with open(self.fn, 'w') as f:
480 (raw_histo_log, max_timestamp_ms) = parse_hist_file(self.fn, 4)
481 self.A(should_not_get_here)
482 except FioHistoLogExc as e:
483 self.A(str(e).startswith('no records'))
485 def test_b3_parse_empty_records(self):
486 with open(self.fn, 'w') as f:
488 f.write('1234, 0, 4096, 1, 2, 3, 4\n')
489 f.write('5678,1,16384,5,6,7,8 \n')
491 (raw_histo_log, max_timestamp_ms) = parse_hist_file(self.fn, 4)
492 self.A(len(raw_histo_log) == 2 and max_timestamp_ms == 5678)
493 (time_ms, direction, bsz, histo) = raw_histo_log[0]
494 self.A(time_ms == 1234 and direction == 0 and bsz == 4096 and histo == [ 1, 2, 3, 4 ])
495 (time_ms, direction, bsz, histo) = raw_histo_log[1]
496 self.A(time_ms == 5678 and direction == 1 and bsz == 16384 and histo == [ 5, 6, 7, 8 ])
498 def test_b4_parse_non_int(self):
499 with open(self.fn, 'w') as f:
500 f.write('12, 0, 4096, 1a, 2, 3, 4\n')
502 (raw_histo_log, _) = parse_hist_file(self.fn, 4)
504 except FioHistoLogExc as e:
505 self.A(str(e).startswith('non-integer'))
507 def test_b5_parse_neg_int(self):
508 with open(self.fn, 'w') as f:
509 f.write('-12, 0, 4096, 1, 2, 3, 4\n')
511 (raw_histo_log, _) = parse_hist_file(self.fn, 4)
513 except FioHistoLogExc as e:
514 self.A(str(e).startswith('negative integer'))
516 def test_b6_parse_too_few_int(self):
517 with open(self.fn, 'w') as f:
520 (raw_histo_log, _) = parse_hist_file(self.fn, 4)
522 except FioHistoLogExc as e:
523 self.A(str(e).startswith('too few numbers'))
525 def test_b7_parse_invalid_direction(self):
526 with open(self.fn, 'w') as f:
527 f.write('100, 2, 4096, 1, 2, 3, 4\n')
529 (raw_histo_log, _) = parse_hist_file(self.fn, 4)
531 except FioHistoLogExc as e:
532 self.A(str(e).startswith('invalid I/O direction'))
534 def test_b8_parse_bsz_too_big(self):
535 with open(self.fn+'_good', 'w') as f:
536 f.write('100, 1, %d, 1, 2, 3, 4\n' % (1<<24))
537 (raw_histo_log, max_timestamp_ms) = parse_hist_file(self.fn+'_good', 4)
538 with open(self.fn+'_bad', 'w') as f:
539 f.write('100, 1, 20000000, 1, 2, 3, 4\n')
541 (raw_histo_log, _) = parse_hist_file(self.fn+'_bad', 4)
543 except FioHistoLogExc as e:
544 self.A(str(e).startswith('block size too large'))
546 def test_b9_parse_wrong_bucket_count(self):
547 with open(self.fn, 'w') as f:
548 f.write('100, 1, %d, 1, 2, 3, 4, 5\n' % (1<<24))
550 (raw_histo_log, _) = parse_hist_file(self.fn, 4)
552 except FioHistoLogExc as e:
553 self.A(str(e).__contains__('buckets per interval'))
555 def test_c1_time_ranges(self):
556 ranges = time_ranges(3, 2) # fio_version defaults to 3
557 expected_ranges = [ # fio_version 3 is in nanoseconds
558 [0.000, 0.001], [0.001, 0.002], # first group
559 [0.002, 0.003], [0.003, 0.004], # second group same width
560 [0.004, 0.006], [0.006, 0.008]] # subsequent groups double width
561 self.A(ranges == expected_ranges)
562 ranges = time_ranges(3, 2, fio_version=3)
563 self.A(ranges == expected_ranges)
564 ranges = time_ranges(3, 2, fio_version=2)
565 expected_ranges_v2 = [ [ 1000.0 * min_or_max for min_or_max in time_range ]
566 for time_range in expected_ranges ]
567 self.A(ranges == expected_ranges_v2)
568 # see fio V3 stat.h for why 29 groups and 2^6 buckets/group
569 normal_ranges_v3 = time_ranges(29, 64)
570 # for v3, bucket time intervals are measured in nanoseconds
571 self.A(len(normal_ranges_v3) == 29 * 64 and normal_ranges_v3[-1][1] == 64*(1<<(29-1))/1000.0)
572 normal_ranges_v2 = time_ranges(19, 64, fio_version=2)
573 # for v2, bucket time intervals are measured in microseconds so we have fewer buckets
574 self.A(len(normal_ranges_v2) == 19 * 64 and normal_ranges_v2[-1][1] == 64*(1<<(19-1)))
576 def test_d1_align_histo_log_1_quantum(self):
577 with open(self.fn, 'w') as f:
578 f.write('100, 1, 4096, 1, 2, 3, 4')
579 (raw_histo_log, max_timestamp_ms) = parse_hist_file(self.fn, 4)
580 self.A(max_timestamp_ms == 100)
581 aligned_log = align_histo_log(raw_histo_log, 5, 4, max_timestamp_ms)
582 self.A(len(aligned_log) == 1)
583 (time_ms0, h) = aligned_log[0]
584 self.A(time_ms0 == 0 and h == [1.0, 2.0, 3.0, 4.0])
586 # we need this to compare 2 lists of floating point numbers for equality
587 # because of floating-point imprecision
589 def compare_2_floats(self, x, y):
590 if x == 0.0 or y == 0.0:
591 return (x+y) < 0.0000001
593 return (math.fabs(x-y)/x) < 0.00001
595 def is_close(self, buckets, buckets_expected):
596 if len(buckets) != len(buckets_expected):
598 compare_buckets = lambda k: self.compare_2_floats(buckets[k], buckets_expected[k])
599 indices_close = list(filter(compare_buckets, range(0, len(buckets))))
600 return len(indices_close) == len(buckets)
602 def test_d2_align_histo_log_2_quantum(self):
603 with open(self.fn, 'w') as f:
604 f.write('2000, 1, 4096, 1, 2, 3, 4\n')
605 f.write('7000, 1, 4096, 1, 2, 3, 4\n')
606 (raw_histo_log, max_timestamp_ms) = parse_hist_file(self.fn, 4)
607 self.A(max_timestamp_ms == 7000)
608 (_, _, _, raw_buckets1) = raw_histo_log[0]
609 (_, _, _, raw_buckets2) = raw_histo_log[1]
610 aligned_log = align_histo_log(raw_histo_log, 5, 4, max_timestamp_ms)
611 self.A(len(aligned_log) == 2)
612 (time_ms1, h1) = aligned_log[0]
613 (time_ms2, h2) = aligned_log[1]
614 # because first record is from time interval [2000, 7000]
615 # we weight it according
616 expect1 = [float(b) * 0.6 for b in raw_buckets1]
617 expect2 = [float(b) * 0.4 for b in raw_buckets1]
618 for e in range(0, len(expect2)):
619 expect2[e] += raw_buckets2[e]
620 self.A(time_ms1 == 0 and self.is_close(h1, expect1))
621 self.A(time_ms2 == 5000 and self.is_close(h2, expect2))
623 # what to expect if histogram buckets are all equal
624 def test_e1_get_pctiles_flat_histo(self):
625 with open(self.fn, 'w') as f:
626 buckets = [ 100 for j in range(0, 128) ]
627 f.write('9000, 1, 4096, %s\n' % ', '.join([str(b) for b in buckets]))
628 (raw_histo_log, max_timestamp_ms) = parse_hist_file(self.fn, 128)
629 self.A(max_timestamp_ms == 9000)
630 aligned_log = align_histo_log(raw_histo_log, 5, 128, max_timestamp_ms)
631 time_intervals = time_ranges(4, 32)
632 # since buckets are all equal, then median is halfway through time_intervals
633 # and max latency interval is at end of time_intervals
634 self.A(time_intervals[64][1] == 0.066 and time_intervals[127][1] == 0.256)
635 pctiles_wanted = [ 0, 50, 100 ]
637 for (time_ms, histo) in aligned_log:
638 pct_vs_time.append(get_pctiles(histo, pctiles_wanted, time_intervals))
639 self.A(pct_vs_time[0] == None) # no I/O in this time interval
640 expected_pctiles = { 0:0.000, 50:0.064, 100:0.256 }
641 self.A(pct_vs_time[1] == expected_pctiles)
643 # what to expect if just the highest histogram bucket is used
644 def test_e2_get_pctiles_highest_pct(self):
645 fio_v3_bucket_count = 29 * 64
646 with open(self.fn, 'w') as f:
647 # make a empty fio v3 histogram
648 buckets = [ 0 for j in range(0, fio_v3_bucket_count) ]
649 # add one I/O request to last bucket
651 f.write('9000, 1, 4096, %s\n' % ', '.join([str(b) for b in buckets]))
652 (raw_histo_log, max_timestamp_ms) = parse_hist_file(self.fn, fio_v3_bucket_count)
653 self.A(max_timestamp_ms == 9000)
654 aligned_log = align_histo_log(raw_histo_log, 5, fio_v3_bucket_count, max_timestamp_ms)
655 (time_ms, histo) = aligned_log[1]
656 time_intervals = time_ranges(29, 64)
657 expected_pctiles = { 100.0:(64*(1<<28))/1000.0 }
658 pct = get_pctiles( histo, [ 100.0 ], time_intervals )
659 self.A(pct == expected_pctiles)
661 # we are using this module as a standalone program
663 if __name__ == '__main__':
664 if os.getenv('UNITTEST'):
665 sys.exit(unittest2.main())
667 compute_percentiles_from_logs()