github.com/lnzx/goofys@v0.24.0/bench/bench_format.py (about) 1 #!/usr/bin/python 2 3 import numpy 4 import sys 5 6 def filter_outliers(numbers, mean, std): 7 if len(numbers) == 1: 8 return numbers 9 return filter(lambda x: abs(x - mean) < 2 * std, numbers) 10 11 op_str = { 12 'create_files' : 'Create 100 files', 13 'create_files_parallel' : 'Create 100 files (parallel)', 14 'rm_files' : 'Unlink 100 files', 15 'rm_files_parallel' : 'Unlink 100 files (parallel)', 16 'ls_files' : 'ls with 1000 files', 17 'find_files' : "`find' with 1000 dirs/files", 18 'write_md5' : 'Write 1GB', 19 'read_first_byte' : 'Time to 1st byte', 20 'read_md5' : 'Read 1GB', 21 } 22 23 outputOrder = [ 24 'create_files', 25 'create_files_parallel', 26 'rm_files', 27 'rm_files_parallel', 28 'ls_files', 29 'find_files', 30 'write_md5', 31 'read_md5', 32 'read_first_byte', 33 ] 34 35 f = sys.argv[1] 36 data = open(f).readlines() 37 #print 'operation | goofys | s3fs | speedup' 38 #print '----------| ------ | ------ | -------' 39 40 table = [{}, {}] 41 has_data = {} 42 43 print('#operation,time') 44 for l in data: 45 dataset = l.strip().split('\t') 46 for d in range(0, len(dataset)): 47 op, num = dataset[d].split(' ') 48 if not op in table[d]: 49 table[d][op] = [] 50 table[d][op] += [float(num)] 51 has_data[op] = True 52 53 54 for c in outputOrder: 55 if c in has_data: 56 sys.stdout.write(op_str[c]) 57 for d in table: 58 mean = numpy.mean(d[c]) 59 err = numpy.std(d[c]) 60 x = filter_outliers(d[c], mean, err) 61 sys.stdout.write("\t%s\t%s\t%s" % (numpy.mean(x), numpy.min(x), numpy.max(x))) 62 print("") 63 64 # op = op_str[nums[0]] 65 66 # for i in range(1, len(nums)): 67 68 # x = map(lambda x: float(x), nums[1].strip().split(' ')) 69 # y = map(lambda x: float(x), nums[2].strip().split(' ')) 70 # mean_x = numpy.mean(x) 71 # err_x = numpy.std(x) 72 # mean_y = numpy.mean(y) 73 # err_y = numpy.std(y) 74 # fixed_x = fixed_y = "" 75 76 # x2 = filter_outliers(x, mean_x, err_x) 77 # y2 = filter_outliers(y, mean_y, err_y) 78 # if x != x2: 79 # fixed_x = "*" * abs(len(x) - len(x2)) 80 # mean_x = numpy.mean(x2) 81 # err_x = numpy.std(x2) 82 # if y != y2: 83 # fixed_y = "*" * abs(len(y) - len(y2)) 84 # mean_y = numpy.mean(y2) 85 # err_y = numpy.std(y2) 86 87 # print "%s, %s, %s, %s", op, mean_x, mean_x - err_x, mean_x + err_x 88 # # u_x = uncertainties.ufloat(mean_x, err_x) 89 # # u_y = uncertainties.ufloat(mean_y, err_y) 90 # # delta = u_y/u_x 91 # # print "%s | %s%s | %s%s | %sx" % (op, u_x, fixed_x, u_y, fixed_y, delta)