# HG changeset patch # User Henry S. Thompson # Date 1691513309 -3600 # Node ID 432915a28952fccc36113548bc186227e2959b3c # Parent e8c667bf8965250e2841b9a0704dad29eabf52a6# Parent e8f89aaa07c175f6b040c4be2ba29ec3acc3df80 merge diff -r e8c667bf8965 -r 432915a28952 bin/deltas.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/deltas.py Tue Aug 08 17:48:29 2023 +0100 @@ -0,0 +1,33 @@ +#!/usr/bin/python3 +'''Extract and tabulate runtimes per file from a slurm output log''' +import sys, re +from datetime import datetime +pending={} +first=None +SPAT=re.compile('... (.*) BST start ([0-9]+ [0-9]+)') +EPAT=re.compile('... (.*) BST end ([0-9]+ [0-9]+)') +with open(sys.argv[1],'r') as f: + for l in f: + if m:=SPAT.match(l): + b=datetime.strptime(m[1],"%d %b %Y %I:%M:%S %p") + id=m[2] + if id in pending: + print('%s started twice at %s, %s'%(id,pending[id],b),file=sys.stderr) + else: + pending[id]=b + if first is None: + first=b + elif m:=EPAT.match(l): + e=datetime.strptime(m[1],"%d %b %Y %I:%M:%S %p") + id=m[2] + if id in pending: + delta=(e-pending[id]).seconds + print(delta,"%2d:%02d"%(delta/60,delta%60),sep='\t') + del pending[id] + else: + print('%s ended w/o start at %s'%(id,e),file=sys.stderr) +w=(e-first).seconds +sys.stdout.flush() +print('From %s to %s:'%(first.strftime("%d %b %Y %I:%M:%S %p"), + e.strftime("%d %b %Y %I:%M:%S %p")),file=sys.stderr) +print(' %d:%02d:%02d'%(w/3600,(w/60)%60,w%60),(e-first).seconds,sep='\t',file=sys.stderr)