Skip to content

Commit

Permalink
makefile: print out maximum memory usage in elapsed
Browse files Browse the repository at this point in the history
Signed-off-by: Øyvind Harboe <[email protected]>
  • Loading branch information
oharboe committed Apr 16, 2024
1 parent afccf3f commit a5cf961
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions flow/util/genElapsedTime.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
def print_log_dir_times(logdir):
first = True
totalElapsed = 0
total_max_memory = 0
print(logdir)

# Loop on all log files in the directory
Expand All @@ -39,8 +40,11 @@ def print_log_dir_times(logdir):
with open(str(f)) as logfile:
found = False
for line in logfile:
elapsedTime = 0
elapsedTime = None
peak_memory = None

# Example line:
# Elapsed time: 0:04.26[h:]min:sec. CPU time: user 4.08 sys 0.17 (99%). Peak memory: 671508KB.
if 'Elapsed time' in line:
found = True
# Extract the portion that has the time
Expand All @@ -61,22 +65,27 @@ def print_log_dir_times(logdir):
else:
print('Elapsed time not understood in',
str(line), file=sys.stderr)
# Find Peak Memory
peak_memory = line.split('Peak memory: ')[1].split('KB')[0]

if not found:
print('No elapsed time found in', str(f), file=sys.stderr)
continue

# Print the name of the step and the corresponding elapsed time
if elapsedTime != 0:
format_str = "%-25s %20s %14s"
if elapsedTime is not None and peak_memory is not None:
if first and not args.noHeader:
print("%-25s %10s" % ("Log", "Elapsed seconds"))
print(format_str %
("Log", "Elapsed seconds", "Peak Memory/KB"))
first = False
print('%-25s %10s' % (os.path.splitext(
os.path.basename(str(f)))[0], elapsedTime))
print(format_str % (os.path.splitext(
os.path.basename(str(f)))[0], elapsedTime, peak_memory))
totalElapsed += elapsedTime
total_max_memory = max(total_max_memory, int(peak_memory))

if totalElapsed != 0:
print("%-25s %10s" % ("Total", totalElapsed))
print(format_str % ("Total", totalElapsed, total_max_memory))


for log_dir in args.logDir:
Expand Down

0 comments on commit a5cf961

Please sign in to comment.