merge-benchmark.py (957B)
1 #!/usr/bin/env python3 2 # See LICENSE file for copyright and license details. 3 4 import sys 5 6 line_count = None 7 files = [] 8 9 for path in sys.argv[1:]: 10 with open(path, 'rb') as file: 11 data = file.read() 12 data = data.decode('utf-8', 'strict') 13 if data[-1] == '\n': 14 data = data[:-1] 15 data = data.split('\n') 16 if line_count is None: 17 line_count = len(data) 18 elif len(data) != line_count: 19 print('%s: line count mismatch' % sys.argv[0], file = sys.stderr) 20 sys.exit(1) 21 files.append(data) 22 23 for i in range(line_count): 24 best_sec = None 25 best_nsec = None 26 best_line = None 27 for lines in files: 28 line = lines[i] 29 [sec, nsec] = line.split(':')[1].split(' ')[1].split('.') 30 [sec, nsec] = [int(sec), int(nsec)] 31 if best_sec is None or sec < best_sec or (sec == best_sec and nsec < best_nsec): 32 best_sec, best_nsec, best_line = sec, nsec, line 33 print(best_line)