def list_stats(l): stats = '\tsamples:%s' % len(l) stats += '\taverage:%s' % timefmt(average(l)) stats += '\tstddev:%s' % timefmt(standard_dev(l)) stats += '\tmax:%s' % max(l) stats += '\tmin:%s' % min(l) return stats
def calculate_stats(stats): """ processing fio json output as dict to return :param stats: a dictionary of the fio format:: {"fio version" : "fio-2.1.4", "jobs" : [ { "jobname" : "results", "groupid" : 0, "error" : 0, "read" : { "io_bytes" : 131072, "bw" : 0, "iops" : 0, "runtime" : 0, "slat" : { "min" : 0, "max" : 0, "mean" : 0.00, "stddev" : 0.00 }, "clat" : { "min" : 0, "max" : 1684, "mean" : 11.34, "stddev" : 31.27, "percentile" : { "1.000000" : 6, "5.000000" : 7, "10.000000" : 7, "20.000000" : 8, "30.000000" : 8, "40.000000" : 8, "50.000000" : 8, "60.000000" : 9, "70.000000" : 9, "80.000000" : 9, "90.000000" : 10, "95.000000" : 14, "99.000000" : 68, "99.500000" : 93, "99.900000" : 438, "99.950000" : 724, "99.990000" : 1320, "0.00" : 0, "0.00" : 0, "0.00" : 0 } }, "lat" : { "min" : 0, "max" : 1684, "mean" : 11.58, "stddev" : 31.32 }, "bw_min" : 0, "bw_max" : 0, "bw_agg" : 0.00, "bw_mean" : 0.00, "bw_dev" : 0.00 }, "write" : { "io_bytes" : 0, "bw" : 0, "iops" : 0, "runtime" : 0, "slat" : { "min" : 0, "max" : 0, "mean" : 0.00, "stddev" : 0.00 }, "clat" : { "min" : 0, "max" : 0, "mean" : 0.00, "stddev" : 0.00, "percentile" : { "1.000000" : 0, "5.000000" : 0, "10.000000" : 0, "20.000000" : 0, "30.000000" : 0, "40.000000" : 0, "50.000000" : 0, "60.000000" : 0, "70.000000" : 0, "80.000000" : 0, "90.000000" : 0, "95.000000" : 0, "99.000000" : 0, "99.500000" : 0, "99.900000" : 0, "99.950000" : 0, "99.990000" : 0, "0.00" : 0, "0.00" : 0, "0.00" : 0 } }, "lat" : { "min" : 0, "max" : 0, "mean" : 0.00, "stddev" : 0.00 }, "bw_min" : 0, "bw_max" : 0, "bw_agg" : 0.00, "bw_mean" : 0.00, "bw_dev" : 0.00 }, "trim" : { "io_bytes" : 0, "bw" : 0, "iops" : 0, "runtime" : 0, "slat" : { "min" : 0, "max" : 0, "mean" : 0.00, "stddev" : 0.00 }, "clat" : { "min" : 0, "max" : 0, "mean" : 0.00, "stddev" : 0.00, "percentile" : { "1.000000" : 0, "5.000000" : 0, "10.000000" : 0, "20.000000" : 0, "30.000000" : 0, "40.000000" : 0, "50.000000" : 0, "60.000000" : 0, "70.000000" : 0, "80.000000" : 0, "90.000000" : 0, "95.000000" : 0, "99.000000" : 0, "99.500000" : 0, "99.900000" : 0, "99.950000" : 0, "99.990000" : 0, "0.00" : 0, "0.00" : 0, "0.00" : 0 } }, "lat" : { "min" : 0, "max" : 0, "mean" : 0.00, "stddev" : 0.00 }, "bw_min" : 0, "bw_max" : 0, "bw_agg" : 0.00, "bw_mean" : 0.00, "bw_dev" : 0.00 }, "usr_cpu" : 0.00, "sys_cpu" : 0.00, "ctx" : 24, "majf" : 0, "minf" : 0, "iodepth_level" : { "1" : 100.00, "2" : 0.00, "4" : 0.00, "8" : 0.00, "16" : 0.00, "32" : 0.00, ">=64" : 0.00 }, "latency_us" : { "2" : 0.01, "4" : 0.00, "10" : 81.63, "20" : 14.22, "50" : 1.86, "100" : 1.83, "250" : 0.29, "500" : 0.06, "750" : 0.05, "1000" : 0.02 }, "latency_ms" : { "2" : 0.03, "4" : 0.00, "10" : 0.00, "20" : 0.00, "50" : 0.00, "100" : 0.00, "250" : 0.00, "500" : 0.00, "750" : 0.00, "1000" : 0.00, "2000" : 0.00, ">=2000" : 0.00 } } ] } returns:: { 'bw': {'average': 900.0, 'deviation': 900.0, 'median': 900.0}, 'iops': {'average': 1010.1, 'deviation': 10.1, 'median': 1010.0}, 'lat': {'average': 0.2, 'deviation': 0.5, 'median': 0.1} } """ iops = list() bw = list() lat = list() for s in stats: bw.append(s[0]) iops.append(s[1]) lat.append(s[2]) report = dict() report['iops'] = {'median': median(iops), 'average': average(iops), 'deviation': standard_dev(iops)} report['bw'] = {'median': median(bw), 'average': average(bw), 'deviation': standard_dev(bw)} report['lat'] = {'median': median(lat), 'average': average(lat), 'deviation': standard_dev(lat)} logger.debug(pformat(report)) return report
def test_standard_deviation(self): self.assertAlmostEqual(standard_dev(self.s), np.std(self.s), 6)