Skip to content

Commit 87e80c4

Browse files
authored
Adding total elapsed time to flow/util/genElapsedTime.py (#1663)
* Adding total elapsed time Signed-off-by: Augusto Berndt <[email protected]> * Fix test with total elapsed --------- Signed-off-by: Augusto Berndt <[email protected]>
1 parent 7d3b325 commit 87e80c4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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 = self.tmp_dir.name + "\n1_test 5400\n"
34+
expected_output = self.tmp_dir.name + "\n1_test 5400\nTotal 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 = self.tmp_dir.name + "\n1_test 744\n"
64+
expected_output = self.tmp_dir.name + "\n1_test 744\nTotal 744\n"
6565
self.assertEqual(mock_stdout.getvalue(), expected_output)
6666

6767
def test_missing_arg(self):

flow/util/genElapsedTime.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
def print_log_dir_times(logdir):
2929
first = True
30+
totalElapsed = 0
3031
print(logdir)
3132

3233
# Loop on all log files in the directory
@@ -65,6 +66,10 @@ def print_log_dir_times(logdir):
6566
print("%-25s %10s" % ("Log", "Elapsed seconds"))
6667
first = False
6768
print('%-25s %10s' % (os.path.splitext(os.path.basename(str(f)))[0], elapsedTime))
69+
totalElapsed += elapsedTime
70+
71+
if totalElapsed != 0:
72+
print("%-25s %10s" % ( "Total", totalElapsed ))
6873

6974
for log_dir in args.logDir:
7075
print_log_dir_times(log_dir)

0 commit comments

Comments
 (0)