Skip to content

Commit f85ca2b

Browse files
author
Vasileios Karakasis
committed
Fine tune implementation of pipeline timing
1 parent ea6edcb commit f85ca2b

File tree

2 files changed

+27
-33
lines changed

2 files changed

+27
-33
lines changed

reframe/frontend/executors/__init__.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,17 @@ def _tf(t):
177177

178178
return msg
179179

180+
def pipeline_timings_all(self):
181+
return self.pipeline_timings([
182+
'setup', 'compile_complete', 'run_complete',
183+
'sanity', 'performance', 'total'
184+
])
185+
186+
def pipeline_timings_basic(self):
187+
return self.pipeline_timings([
188+
'compile_complete', 'run_complete', 'total'
189+
])
190+
180191
@property
181192
def testcase(self):
182193
return self._case
@@ -210,27 +221,28 @@ def _safe_call(self, fn, *args, **kwargs):
210221
class update_timestamps:
211222
'''Context manager to set the start and finish timestamps.'''
212223

213-
def __init__(self, obj):
214-
self.obj = obj
215-
216-
def __enter__(self):
224+
# We use `this` to refer to the update_timestamps object, because
225+
# we don't want to masquerade the self argument of our containing
226+
# function
227+
def __enter__(this):
217228
if fn.__name__ != 'poll':
218-
cs = self.obj._current_stage
219-
self.obj._timestamps[f'{cs}_start'] = time.time()
229+
stage = self._current_stage
230+
self._timestamps[f'{stage}_start'] = time.time()
220231

221-
def __exit__(self, exc_type, exc_value, traceback):
222-
cs = self.obj._current_stage
223-
self.obj._timestamps[f'{cs}_finish'] = time.time()
224-
self.obj._timestamps['pipeline_end'] = time.time()
232+
def __exit__(this, exc_type, exc_value, traceback):
233+
stage = self._current_stage
234+
self._timestamps[f'{stage}_finish'] = time.time()
235+
self._timestamps['pipeline_end'] = time.time()
225236

226237
if fn.__name__ != 'poll':
227238
self._current_stage = fn.__name__
228239

229240
try:
230241
with logging.logging_context(self.check) as logger:
231242
logger.debug(f'entering stage: {self._current_stage}')
232-
with update_timestamps(self):
243+
with update_timestamps():
233244
return fn(*args, **kwargs)
245+
234246
except ABORT_REASONS:
235247
self.fail()
236248
raise

reframe/frontend/executors/policies.py

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -227,37 +227,19 @@ def on_task_run(self, task):
227227
self._running_tasks.append(task)
228228

229229
def on_task_failure(self, task):
230-
timings = task.pipeline_timings(['compile_complete',
231-
'run_complete',
232-
'total'])
233-
msg = f'{task.check.info()} [{timings}]'
230+
msg = f'{task.check.info()} [{task.pipeline_timings_basic()}]'
234231
if task.failed_stage == 'cleanup':
235232
self.printer.status('ERROR', msg, just='right')
236233
else:
237234
self._remove_from_running(task)
238235
self.printer.status('FAIL', msg, just='right')
239236

240-
timings = task.pipeline_timings(['setup',
241-
'compile_complete',
242-
'run_complete',
243-
'sanity',
244-
'performance',
245-
'total'])
246-
getlogger().verbose(f"==> {timings}")
237+
getlogger().verbose(f"==> {task.pipeline_timings_all()}")
247238

248239
def on_task_success(self, task):
249-
timings = task.pipeline_timings(['compile_complete',
250-
'run_complete',
251-
'total'])
252-
msg = f'{task.check.info()} [{timings}]'
240+
msg = f'{task.check.info()} [{task.pipeline_timings_basic()}]'
253241
self.printer.status('OK', msg, just='right')
254-
timings = task.pipeline_timings(['setup',
255-
'compile_complete',
256-
'run_complete',
257-
'sanity',
258-
'performance',
259-
'total'])
260-
getlogger().verbose(f"==> {timings}")
242+
getlogger().verbose(f"==> {task.pipeline_timings_all()}")
261243
# update reference count of dependencies
262244
for c in task.testcase.deps:
263245
self._task_index[c].ref_count -= 1

0 commit comments

Comments
 (0)