Skip to content

Commit 65f4541

Browse files
Merge pull request #1186 from douglasjacobsen/time-exeternal-commands
Add timing to command runner commands
2 parents 509f63d + 13a93a1 commit 65f4541

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/ramble/ramble/util/command_runner.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
66
# option. This file may not be copied, modified, or distributed
77
# except according to those terms.
8+
import time
89
from typing import List
910

1011
from ramble.util.executable import which
@@ -29,6 +30,7 @@ def __init__(self, name=None, command=None, shell="bash", dry_run=False, path=No
2930
self.name = name
3031
self.dry_run = dry_run
3132
self.shell = shell
33+
self.elapsed_time = 0
3234
required = not self.dry_run
3335
try:
3436
if path is None:
@@ -116,6 +118,7 @@ def _cmd_end(self, executable, args):
116118
logger.msg("")
117119
logger.msg(banner)
118120
logger.msg(finished_str)
121+
logger.msg(f"** Took {self.elapsed_time} seconds")
119122
logger.msg(banner)
120123
logger.msg("")
121124

@@ -137,6 +140,7 @@ def _run_command(self, executable, args, allow_failure=False, return_output=Fals
137140

138141
self._cmd_start(executable, args)
139142
out_str = None
143+
start_time = time.time()
140144
try:
141145
if active_stream is None:
142146
if return_output:
@@ -153,6 +157,7 @@ def _run_command(self, executable, args, allow_failure=False, return_output=Fals
153157
logger.error(e)
154158
error = True
155159
pass
160+
self.elapsed_time = time.time() - start_time
156161

157162
if error:
158163
err = f"Error running {self.name} command: {executable} " + " ".join(args)

0 commit comments

Comments
 (0)