From 0337af7f406ca73dd978be3c4c473658a3ea525e Mon Sep 17 00:00:00 2001 From: Klaus Rabbertz <klaus.rabbertz@cern.ch> Date: Tue, 9 Apr 2024 21:19:19 +0200 Subject: [PATCH] Do not use anymore information from run cards (might be missing anyway) for times and event numbers --- tools/plotting/fastnnlo_runtime.py | 53 ++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/tools/plotting/fastnnlo_runtime.py b/tools/plotting/fastnnlo_runtime.py index 2d0b9ef0..29430ba9 100755 --- a/tools/plotting/fastnnlo_runtime.py +++ b/tools/plotting/fastnnlo_runtime.py @@ -92,15 +92,16 @@ def main(): # extract correct paths for input and outputfiles files = get_files(args['logfiles']) logfiles = [] - runfiles = [] + # runfiles = [] for file in files: - runfile = re.sub('.log$', '.run', file) - if not os.path.isfile(runfile): - print('[fastnnlo_runtime]: WARNING! No matching runcard found for log file {}, skipped!') - else: - logfiles.append(file) - runfiles.append(runfile) - outputpath = args['output'] + # print(file) + # runfile = re.sub('.log$', '.run', file) + # if not os.path.isfile(runfile): + # print('[fastnnlo_runtime]: WARNING! No matching runcard found for log file {}, skipped!') + # else: + logfiles.append(file) + # runfiles.append(runfile) + outputpath = args['output'] print('[fastnnlo_runtime]: Output path argument is: {}'.format(outputpath)) outputname = args['filename'] print('[fastnnlo_runtime]: Filename argument is: {}'.format(outputname)) @@ -120,10 +121,12 @@ def main(): exit(1) # 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) - runinformation = get_runinformation(runfiles) - info = {**loginformation, **runinformation} + # DEPRECATED: Do not use anymore information from run cards (might be missing anyway) + # runinformation = get_runinformation(runfiles) + # info = {**loginformation, **runinformation} + info = {**loginformation} # plot all the information if args['CPUtime']: @@ -173,17 +176,33 @@ def get_files(files): def get_loginformation(files): + # get this also from log files instead of the run cards + nevents = [] + channels = [] + # always in hours for simplicity runtimes = [] numcores = [] unit = 'hours' for file in files: + nevents_temp = [] + channels_temp = [] runtimes_temp = [] numcores_temp = [] with open(file) as 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 if 'Time elapsed' in line: line = line.split(':') @@ -192,17 +211,24 @@ def get_loginformation(files): seconds = float(line[3]) runtimes_temp.append(hours + minutes/60 + seconds/3600) + # extract number of threads if 'Allocated number of threads' in line: line = line.split(':') numcores_temp.append(int(line[1])) + nevents.append(nevents_temp[-1]) + channels.append(channels_temp[-1]) runtimes.append(runtimes_temp[-1]) numcores.append(numcores_temp[-1]) + nevents = np.array(nevents) + channels = np.array(channels) runtimes = np.array(runtimes) numcores = np.array(numcores) information = { + 'channels': channels, + 'events': nevents, 'runtimes': runtimes, 'runtime_unit': unit, 'numcores': numcores @@ -210,6 +236,7 @@ def get_loginformation(files): return information +# DEPRECATED: Do not use anymore information from run cards (might be missing anyway) def get_runinformation(files): nevents = [] @@ -279,9 +306,9 @@ def plot_elapsed_time(infodict, out_path, out_name, formats): mean = np.mean(times) std = np.std(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?: - # 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) -- GitLab