Skip to content
Snippets Groups Projects
Commit 0337af7f authored by Klaus Rabbertz's avatar Klaus Rabbertz
Browse files

Do not use anymore information from run cards (might be missing anyway) for times and event numbers

parent 32219fe0
Branches
Tags
No related merge requests found
...@@ -92,14 +92,15 @@ def main(): ...@@ -92,14 +92,15 @@ def main():
# extract correct paths for input and outputfiles # extract correct paths for input and outputfiles
files = get_files(args['logfiles']) files = get_files(args['logfiles'])
logfiles = [] logfiles = []
runfiles = [] # runfiles = []
for file in files: for file in files:
runfile = re.sub('.log$', '.run', file) # print(file)
if not os.path.isfile(runfile): # runfile = re.sub('.log$', '.run', file)
print('[fastnnlo_runtime]: WARNING! No matching runcard found for log file {}, skipped!') # if not os.path.isfile(runfile):
else: # print('[fastnnlo_runtime]: WARNING! No matching runcard found for log file {}, skipped!')
# else:
logfiles.append(file) logfiles.append(file)
runfiles.append(runfile) # runfiles.append(runfile)
outputpath = args['output'] outputpath = args['output']
print('[fastnnlo_runtime]: Output path argument is: {}'.format(outputpath)) print('[fastnnlo_runtime]: Output path argument is: {}'.format(outputpath))
outputname = args['filename'] outputname = args['filename']
...@@ -120,10 +121,12 @@ def main(): ...@@ -120,10 +121,12 @@ def main():
exit(1) exit(1)
# get all the information from logfiles as dict # get all the information from logfiles as dict
# dict contains: runtimes, runtime_unit, numcores; channel, events # dict contains: channels, events, runtimes, runtime_unit, numcores
loginformation = get_loginformation(logfiles) loginformation = get_loginformation(logfiles)
runinformation = get_runinformation(runfiles) # DEPRECATED: Do not use anymore information from run cards (might be missing anyway)
info = {**loginformation, **runinformation} # runinformation = get_runinformation(runfiles)
# info = {**loginformation, **runinformation}
info = {**loginformation}
# plot all the information # plot all the information
if args['CPUtime']: if args['CPUtime']:
...@@ -173,17 +176,33 @@ def get_files(files): ...@@ -173,17 +176,33 @@ def get_files(files):
def get_loginformation(files): def get_loginformation(files):
# get this also from log files instead of the run cards
nevents = []
channels = []
# always in hours for simplicity # always in hours for simplicity
runtimes = [] runtimes = []
numcores = [] numcores = []
unit = 'hours' unit = 'hours'
for file in files: for file in files:
nevents_temp = []
channels_temp = []
runtimes_temp = [] runtimes_temp = []
numcores_temp = [] numcores_temp = []
with open(file) as origin: with open(file) as origin:
for line in origin: for line in origin:
# extract nevents
if 'Number of events' in line:
line = line.split()
nevents_temp.append(int(line[3]))
# extract channel
if 'loadNextContrib_chan' in line:
line = line.split()
channels_temp.append(line[2])
# extract elapsed time in hours # extract elapsed time in hours
if 'Time elapsed' in line: if 'Time elapsed' in line:
line = line.split(':') line = line.split(':')
...@@ -192,17 +211,24 @@ def get_loginformation(files): ...@@ -192,17 +211,24 @@ def get_loginformation(files):
seconds = float(line[3]) seconds = float(line[3])
runtimes_temp.append(hours + minutes/60 + seconds/3600) runtimes_temp.append(hours + minutes/60 + seconds/3600)
# extract number of threads
if 'Allocated number of threads' in line: if 'Allocated number of threads' in line:
line = line.split(':') line = line.split(':')
numcores_temp.append(int(line[1])) numcores_temp.append(int(line[1]))
nevents.append(nevents_temp[-1])
channels.append(channels_temp[-1])
runtimes.append(runtimes_temp[-1]) runtimes.append(runtimes_temp[-1])
numcores.append(numcores_temp[-1]) numcores.append(numcores_temp[-1])
nevents = np.array(nevents)
channels = np.array(channels)
runtimes = np.array(runtimes) runtimes = np.array(runtimes)
numcores = np.array(numcores) numcores = np.array(numcores)
information = { information = {
'channels': channels,
'events': nevents,
'runtimes': runtimes, 'runtimes': runtimes,
'runtime_unit': unit, 'runtime_unit': unit,
'numcores': numcores 'numcores': numcores
...@@ -210,6 +236,7 @@ def get_loginformation(files): ...@@ -210,6 +236,7 @@ def get_loginformation(files):
return information return information
# DEPRECATED: Do not use anymore information from run cards (might be missing anyway)
def get_runinformation(files): def get_runinformation(files):
nevents = [] nevents = []
...@@ -279,9 +306,9 @@ def plot_elapsed_time(infodict, out_path, out_name, formats): ...@@ -279,9 +306,9 @@ def plot_elapsed_time(infodict, out_path, out_name, formats):
mean = np.mean(times) mean = np.mean(times)
std = np.std(times) std = np.std(times)
median = np.median(times) median = np.median(times)
iqd = np.subtract(*np.percentile(times, [75, 25], interpolation='linear'))/2. # iqd = np.subtract(*np.percentile(times, [75, 25], interpolation='linear'))/2.
# In future?: # In future?:
# iqd = np.subtract(*np.percentile(times, [75, 25], method='linear'))/2. iqd = np.subtract(*np.percentile(times, [75, 25], method='linear'))/2.
CPUtime = np.sum(cputimes) CPUtime = np.sum(cputimes)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment