Skip to content

Commit 36ded7b

Browse files
committed
Added recording timestamps
1 parent 97d33bb commit 36ded7b

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

nipype/interfaces/tests/test_runtime_profiler.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,20 @@ def _collect_range_runtime_stats(self, num_threads):
154154
# Iterate through all combos
155155
for num_gb in np.arange(0.25, ram_gb_range+ram_gb_step, ram_gb_step):
156156
# Cmd-level
157-
cmd_fin_str = self._run_cmdline_workflow(num_gb, num_threads)
157+
cmd_start_str, cmd_fin_str = self._run_cmdline_workflow(num_gb, num_threads)
158+
cmd_start_ts = json.loads(cmd_start_str)['start']
158159
cmd_node_stats = json.loads(cmd_fin_str)
159160
cmd_runtime_threads = int(cmd_node_stats['runtime_threads'])
160161
cmd_runtime_gb = float(cmd_node_stats['runtime_memory_gb'])
162+
cmd_finish_ts = cmd_node_stats['finish']
161163

162164
# Func-level
163-
func_fin_str = self._run_function_workflow(num_gb, num_threads)
165+
func_start_str, func_fin_str = self._run_function_workflow(num_gb, num_threads)
166+
func_start_ts = json.loads(func_start_str)['start']
164167
func_node_stats = json.loads(func_fin_str)
165168
func_runtime_threads = int(func_node_stats['runtime_threads'])
166169
func_runtime_gb = float(func_node_stats['runtime_memory_gb'])
170+
func_finish_ts = func_node_stats['finish']
167171

168172
# Calc errors
169173
cmd_threads_err = cmd_runtime_threads - num_threads
@@ -181,7 +185,11 @@ def _collect_range_runtime_stats(self, num_threads):
181185
'cmd_threads_err' : cmd_threads_err,
182186
'cmd_gb_err' : cmd_gb_err,
183187
'func_threads_err' : func_threads_err,
184-
'func_gb_err' : func_gb_err}
188+
'func_gb_err' : func_gb_err,
189+
'cmd_start_ts' : cmd_start_ts,
190+
'cmd_finish_ts' : cmd_finish_ts,
191+
'func_start_ts' : func_start_ts,
192+
'func_finish_ts' : func_finish_ts}
185193
# Append to list
186194
dict_list.append(results_dict)
187195

@@ -262,13 +270,14 @@ def _run_cmdline_workflow(self, num_gb, num_threads):
262270
wf.run(plugin='MultiProc', plugin_args=plugin_args)
263271

264272
# Get runtime stats from log file
273+
start_str = open(log_file, 'r').readlines()[0].rstrip('\n')
265274
finish_str = open(log_file, 'r').readlines()[1].rstrip('\n')
266275

267276
# Delete wf base dir
268277
shutil.rmtree(base_dir)
269278

270279
# Return runtime stats
271-
return finish_str
280+
return start_str, finish_str
272281

273282
# Test node
274283
def _run_function_workflow(self, num_gb, num_threads):
@@ -339,13 +348,14 @@ def _run_function_workflow(self, num_gb, num_threads):
339348
wf.run(plugin='MultiProc', plugin_args=plugin_args)
340349

341350
# Get runtime stats from log file
351+
start_str = open(log_file, 'r').readlines()[0].rstrip('\n')
342352
finish_str = open(log_file, 'r').readlines()[1].rstrip('\n')
343353

344354
# Delete wf base dir
345355
shutil.rmtree(base_dir)
346356

347357
# Return runtime stats
348-
return finish_str
358+
return start_str, finish_str
349359

350360
# Test resources were used as expected in cmdline interface
351361
@unittest.skipIf(run_profiler == False, skip_profile_msg)
@@ -364,7 +374,7 @@ def tiest_cmdline_profiling(self):
364374
num_threads = self.num_threads
365375

366376
# Run workflow and get stats
367-
finish_str = self._run_cmdline_workflow(num_gb, num_threads)
377+
start_str, finish_str = self._run_cmdline_workflow(num_gb, num_threads)
368378
# Get runtime stats as dictionary
369379
node_stats = json.loads(finish_str)
370380

@@ -406,7 +416,7 @@ def tiest_function_profiling(self):
406416
num_threads = self.num_threads
407417

408418
# Run workflow and get stats
409-
finish_str = self._run_function_workflow(num_gb, num_threads)
419+
start_str, finish_str = self._run_function_workflow(num_gb, num_threads)
410420
# Get runtime stats as dictionary
411421
node_stats = json.loads(finish_str)
412422

0 commit comments

Comments
 (0)