Skip to content

Commit

Permalink
ENH: MeasureStartupTimes: Add option to benchmark only regular startup
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.slicer.org/Slicer4/trunk@25112 3bd1e089-480b-0410-8dfb-8563597acbee
  • Loading branch information
jcfr committed May 23, 2016
1 parent d9eaf67 commit 4095862
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Applications/SlicerApp/Testing/Python/MeasureStartupTimes.py
Expand Up @@ -42,6 +42,14 @@ def TemporaryPythonScript(code, *args, **kwargs):
print("Written script %s [%s]" % (script.name, code))
return script

def collect_startup_times_normal(output_file, drop_cache=False):
results= {}
test = []
(duration, result) = runSlicerAndExitWithTime(slicer_executable, test, drop_cache=drop_cache)
results[" ".join(test)] = duration
with open(output_file, 'w') as file:
file.write(json.dumps(results, indent=4))

def collect_startup_times_overall(output_file, drop_cache=False):

tests = [
Expand Down Expand Up @@ -128,18 +136,26 @@ def collect_startup_times_excluding_one_module(output_file, drop_cache=False):
if __name__ == '__main__':

parser = argparse.ArgumentParser(description='Measure startup times.')
# Experiments
parser.add_argument("--normal", action="store_true")
parser.add_argument("--overall", action="store_true")
parser.add_argument("--excluding-one-module", action="store_true")
# Common options
parser.add_argument("-n", "--repeat", default=1, type=int)
parser.add_argument("--drop-cache", action="store_true")
parser.add_argument("/path/to/Slicer")
args = parser.parse_args()

slicer_executable = os.path.expanduser(getattr(args, "/path/to/Slicer"))
all = not args.overall and not args.excluding_one_module
all = not args.overall and not args.excluding_one_module and not args.normal

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

# Since the "normal" experiment is included in the "overall" one,
# it is not executed by default.
if args.normal:
collect_startup_times_normal("StartupTimesNormal.json", drop_cache=args.drop_cache)

if all or args.overall:
collect_startup_times_overall("StartupTimes.json", drop_cache=args.drop_cache)

Expand Down

0 comments on commit 4095862

Please sign in to comment.