Skip to content

Instantly share code, notes, and snippets.

@luismarques
Created December 18, 2020 14:41
Show Gist options
  • Save luismarques/81c114309931afa52eec0a878a212f3e to your computer and use it in GitHub Desktop.
Save luismarques/81c114309931afa52eec0a878a212f3e to your computer and use it in GitHub Desktop.
import dateutil.parser
import re
date_re = r'(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|[+-](?:2[0-3]|[01][0-9]):[0-5][0-9])?'
full_re = f'({date_re}) (\[(\d*)/\d*\]) (.*)'
match = re.compile(full_re).match
def process_log(lines):
last_date = None
total_time = 0
times = {}
i = 1
for line in lines:
# remove extra time precision, that causes ISO date parsing to fail
line = line[:26] + line[27:]
m = match(line)
if not m:
continue
date = m.group(1)
date = dateutil.parser.isoparse(date)
step = int(m.group(11))
msg = m.group(12)
assert(step == i)
i = i + 1
if last_date is not None:
time = (date - last_date).total_seconds()
times[msg] = time
total_time = total_time + time
last_date = date
return times
f = open('gcc.txt', 'r')
lines = f.readlines()
times_gcc = process_log(lines)
f = open('clang.txt', 'r')
lines = f.readlines()
times_clang = process_log(lines)
for msg, t_clang in times_clang.items():
t_gcc = times_gcc[msg]
t_ratio = t_clang / t_gcc
#print(f'{t_clang} {t_gcc} {msg}')
print(f'{t_ratio} {t_gcc} {t_clang} {msg}')
#print(total_time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment