@@ -411,6 +411,26 @@ def vtr_command_argparser(prog=None):
411
411
return parser
412
412
413
413
414
+ def format_human_readable_memory (num_kbytes ):
415
+ """format the number of bytes given as a human readable value"""
416
+ if num_kbytes < 1024 :
417
+ value = "%.2f KiB" % (num_kbytes )
418
+ elif num_kbytes < (1024 ** 2 ):
419
+ value = "%.2f MiB" % (num_kbytes / (1024 ** 1 ))
420
+ else :
421
+ value = "%.2f GiB" % (num_kbytes / (1024 ** 2 ))
422
+ return value
423
+
424
+
425
+ def get_memory_usage (logfile ):
426
+ """Extrats the memory usage from the *.out log files"""
427
+ with open (logfile , "r" ) as fpmem :
428
+ for line in fpmem .readlines ():
429
+ if "Maximum resident set size" in line :
430
+ return format_human_readable_memory (int (line .split ()[- 1 ]))
431
+ return "--"
432
+
433
+
414
434
# pylint: enable=too-many-statements
415
435
416
436
@@ -488,9 +508,12 @@ def vtr_command_main(arg_list, prog=None):
488
508
489
509
finally :
490
510
seconds = datetime .now () - start
511
+
491
512
print (
492
- "{status} (took {time})" .format (
493
- status = error_status , time = vtr .format_elapsed_time (seconds )
513
+ "{status} (took {time}, vpr run consumed {max_mem} memory)" .format (
514
+ status = error_status ,
515
+ time = vtr .format_elapsed_time (seconds ),
516
+ max_mem = get_memory_usage (temp_dir / "vpr.out" ),
494
517
)
495
518
)
496
519
temp_dir .mkdir (parents = True , exist_ok = True )
0 commit comments