Skip to content

Commit ac4e3f5

Browse files
authored
Merge pull request #1409 from Pinata-Consulting/make-elapsed-blocks
make: elapsed prints times for BLOCKS
2 parents 1c42900 + ca71379 commit ac4e3f5

File tree

3 files changed

+48
-42
lines changed

3 files changed

+48
-42
lines changed

flow/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ ifdef BLOCKS
210210
$(foreach block,$(BLOCKS),$(eval BLOCK_LIBS += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/${block}.lib))
211211
$(foreach block,$(BLOCKS),$(eval BLOCK_GDS += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/6_final.gds))
212212
$(foreach block,$(BLOCKS),$(eval BLOCK_CDL += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/6_final.cdl))
213+
$(foreach block,$(BLOCKS),$(eval BLOCK_LOG_FOLDERS += ./logs/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/))
213214
export ADDITIONAL_LEFS += $(BLOCK_LEFS)
214215
export ADDITIONAL_LIBS += $(BLOCK_LIBS)
215216
export ADDITIONAL_GDS += $(BLOCK_GDS)
@@ -719,7 +720,7 @@ finish: $(LOG_DIR)/6_report.log \
719720

720721
.PHONY: elapsed
721722
elapsed:
722-
-@$(UTILS_DIR)/genElapsedTime.py -d "$(LOG_DIR)"
723+
-@$(UTILS_DIR)/genElapsedTime.py -d $(BLOCK_LOG_FOLDERS) $(LOG_DIR)
723724

724725
# ==============================================================================
725726

flow/test/test_genElapsedTime.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_elapsed_time(self, mock_stdout):
3131
with patch.object(sys, 'argv', sys.argv):
3232
module = importlib.import_module(self.module_name)
3333
# check if output is correct
34-
expected_output = "1_test 5400\n"
34+
expected_output = self.tmp_dir.name + "\n1_test 5400\n"
3535
self.assertEqual(mock_stdout.getvalue(), expected_output)
3636

3737
@patch("sys.stdout", new_callable=StringIO)
@@ -61,7 +61,7 @@ def test_elapsed_time_longer_duration(self, mock_stdout):
6161
module = importlib.import_module(self.module_name)
6262
importlib.reload(module)
6363
# check if output is correct
64-
expected_output = "1_test 744\n"
64+
expected_output = self.tmp_dir.name + "\n1_test 744\n"
6565
self.assertEqual(mock_stdout.getvalue(), expected_output)
6666

6767
def test_missing_arg(self):

flow/util/genElapsedTime.py

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# ==============================================================================
1414
parser = argparse.ArgumentParser(
1515
description='Print elapsed time for every step in the flow')
16-
parser.add_argument('--logDir', '-d', required=True,
17-
help='Log files directory')
16+
parser.add_argument('--logDir', '-d', required=True, nargs='+',
17+
help='Log files directories')
1818
parser.add_argument('--noHeader', action='store_true',
1919
help='Skip the header')
2020
args = parser.parse_args()
@@ -25,41 +25,46 @@
2525
parser.print_help()
2626
sys.exit(1)
2727

28-
first = True
29-
30-
# Loop on all log files in the directory
31-
for f in sorted(pathlib.Path(args.logDir).glob('**/[0-9]_*.log')):
32-
# Extract Elapsed Time line from log file
33-
with open(str(f)) as logfile:
34-
found = False
35-
for line in logfile:
36-
elapsedTime = 0
37-
38-
if 'Elapsed time' in line:
39-
found = True
40-
# Extract the portion that has the time
41-
timePor = line.strip().replace('Elapsed time: ', '')
42-
# Remove the units from the time portion
43-
timePor = timePor.split('[h:]', 1)[0]
44-
# Remove any fraction of a second
45-
timePor = timePor.split('.', 1)[0]
46-
# Calculate elapsed time that has this format 'h:m:s'
47-
timeList = timePor.split(':')
48-
if len(timeList) == 2:
49-
# Only minutes and seconds are present
50-
elapsedTime = int(timeList[0])*60 + int(timeList[1])
51-
elif len(timeList) == 3:
52-
# Hours, minutes, and seconds are present
53-
elapsedTime = int(timeList[0])*3600 + int(timeList[1])*60 + int(timeList[2])
54-
else:
55-
print('Elapsed time not understood in', str(line), file=sys.stderr)
28+
def print_log_dir_times(logdir):
29+
first = True
30+
print(logdir)
5631

57-
if not found:
58-
print('No elapsed time found in', str(f), file=sys.stderr)
59-
60-
# Print the name of the step and the corresponding elapsed time
61-
if elapsedTime != 0:
62-
if first and not args.noHeader:
63-
print("%-25s %10s" % ("Log", "Elapsed seconds"))
64-
first = False
65-
print('%-25s %10s' % (os.path.splitext(os.path.basename(str(f)))[0], elapsedTime))
32+
# Loop on all log files in the directory
33+
for f in sorted(pathlib.Path(logdir).glob('**/[0-9]_*.log')):
34+
# Extract Elapsed Time line from log file
35+
with open(str(f)) as logfile:
36+
found = False
37+
for line in logfile:
38+
elapsedTime = 0
39+
40+
if 'Elapsed time' in line:
41+
found = True
42+
# Extract the portion that has the time
43+
timePor = line.strip().replace('Elapsed time: ', '')
44+
# Remove the units from the time portion
45+
timePor = timePor.split('[h:]', 1)[0]
46+
# Remove any fraction of a second
47+
timePor = timePor.split('.', 1)[0]
48+
# Calculate elapsed time that has this format 'h:m:s'
49+
timeList = timePor.split(':')
50+
if len(timeList) == 2:
51+
# Only minutes and seconds are present
52+
elapsedTime = int(timeList[0])*60 + int(timeList[1])
53+
elif len(timeList) == 3:
54+
# Hours, minutes, and seconds are present
55+
elapsedTime = int(timeList[0])*3600 + int(timeList[1])*60 + int(timeList[2])
56+
else:
57+
print('Elapsed time not understood in', str(line), file=sys.stderr)
58+
59+
if not found:
60+
print('No elapsed time found in', str(f), file=sys.stderr)
61+
62+
# Print the name of the step and the corresponding elapsed time
63+
if elapsedTime != 0:
64+
if first and not args.noHeader:
65+
print("%-25s %10s" % ("Log", "Elapsed seconds"))
66+
first = False
67+
print('%-25s %10s' % (os.path.splitext(os.path.basename(str(f)))[0], elapsedTime))
68+
69+
for log_dir in args.logDir:
70+
print_log_dir_times(log_dir)

0 commit comments

Comments
 (0)