Skip to content

Commit a3f8090

Browse files
committed
ENH: MeasureStartupTimes: Add --reuse-module-list option
Add convenience option allowing to reuse existing 'Modules.json' file, it allows to more quickly get feedback without having to wait for the function "collect_modules" to complete. git-svn-id: http://svn.slicer.org/Slicer4/trunk@25131 3bd1e089-480b-0410-8dfb-8563597acbee
1 parent be33d13 commit a3f8090

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Applications/SlicerApp/Testing/Python/MeasureStartupTimes.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,14 @@ def collect_startup_times_overall(output_file, drop_cache=False):
7575
with open(output_file, 'w') as file:
7676
file.write(json.dumps(results, indent=4))
7777

78-
def collect_modules():
78+
def read_modules(input_file='Modules.json'):
79+
# Read list of modules
80+
with open(input_file) as input:
81+
modules = json.load(input)
82+
print("Found %d modules reading %s\n" % (len(modules), input_file))
83+
return modules
84+
85+
def collect_modules(output_file='Modules.json'):
7986
# Collect list of all modules and their associated types
8087
python_script = TemporaryPythonScript("""
8188
import json
@@ -107,11 +114,7 @@ def collect_modules():
107114
assert returnCode == EXIT_SUCCESS
108115
print("=> ok\n")
109116

110-
# Read list of modules
111-
with open('Modules.json') as input:
112-
modules = json.load(input)
113-
print("Found %d modules\n" % len(modules))
114-
return modules
117+
return read_modules(output_file)
115118

116119
def collect_startup_times_including_one_module(output_file, drop_cache=False):
117120
modules = collect_modules()
@@ -182,6 +185,7 @@ def collect_startup_times_modules_to_load(output_file, modules_to_load, drop_cac
182185
# Common options
183186
parser.add_argument("-n", "--repeat", default=1, type=int)
184187
parser.add_argument("--drop-cache", action="store_true")
188+
parser.add_argument("--reuse-module-list", action="store_true")
185189
parser.add_argument("/path/to/Slicer")
186190
args = parser.parse_args()
187191

@@ -194,6 +198,10 @@ def collect_startup_times_modules_to_load(output_file, modules_to_load, drop_cac
194198

195199
runSlicerAndExitWithTime = timecall(runSlicerAndExit, repeat=args.repeat)
196200

201+
if args.reuse_module_list:
202+
print("Loading existing module listing")
203+
collect_modules = read_modules
204+
197205
# Since the "normal" experiment is included in the "overall" one,
198206
# it is not executed by default.
199207
if args.normal:

0 commit comments

Comments
 (0)