Mercurial > hg > cc > cirrus_work
view lib/python/deltas.py @ 257:3ac7e5ec07f9 default tip
renamed cpython class Cdb to CCdb to avoid name conflict with cdb.Cdb
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Thu, 23 Jan 2025 12:53:28 +0000 |
parents | 1d1bd22124c0 |
children |
line wrap: on
line source
#!/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)