-
Notifications
You must be signed in to change notification settings - Fork 17
/
performance_check.py
55 lines (45 loc) · 2.42 KB
/
performance_check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# SPDX-FileCopyrightText: 2021 Division of Intelligent Medical Systems, DKFZ
# SPDX-FileCopyrightText: 2021 Janek Groehl
# SPDX-License-Identifier: MIT
import pathlib
import os
from argparse import ArgumentParser
def run_benchmarking_tests(spacing=0.4, profile: str = "TIME", savefolder: str = 'default'):
"""
:param spacing: Simulation spacing in mm
:param profile: What tag to choose to benchmark the examples
:param savefolder: where to save the results
:return: file with benchmarking data line by line
"""
spacing = float(spacing)
os.environ["SIMPA_PROFILE"] = profile
if savefolder == 'default':
savefolder = (str(pathlib.Path(__file__).parent.resolve()) + "/benchmarking_data_" + profile + "_"
+ str(spacing) + ".txt")
os.environ["SIMPA_PROFILE_SAVE_FILE"] = savefolder
elif savefolder == 'print':
pass
elif len(savefolder) > 0:
os.environ["SIMPA_PROFILE_SAVE_FILE"] = savefolder+"/benchmarking_data_"+profile+"_"+str(spacing)+".txt"
from simpa_examples.minimal_optical_simulation import run_minimal_optical_simulation
from simpa_examples.minimal_optical_simulation_uniform_cube import run_minimal_optical_simulation_uniform_cube
from simpa_examples.optical_and_acoustic_simulation import run_optical_and_acoustic_simulation
from simpa_examples.segmentation_loader import run_segmentation_loader
from simpa_examples.three_vs_two_dimensional_simulation_example import (
run_three_vs_two_dimensional_simulation_example)
examples = [run_minimal_optical_simulation,
run_minimal_optical_simulation_uniform_cube,
run_optical_and_acoustic_simulation,
run_segmentation_loader,
run_three_vs_two_dimensional_simulation_example
]
for example in examples:
example(spacing=spacing, path_manager=None, visualise=False)
if __name__ == "__main__":
parser = ArgumentParser(description='Run benchmarking tests')
parser.add_argument("--spacing", default=0.2, help='the voxel spacing in mm')
parser.add_argument("--profile", default="TIME", type=str,
help='the profile to run')
parser.add_argument("--savefolder", default='default', type=str, help='where to save the results')
config = parser.parse_args()
run_benchmarking_tests(spacing=float(config.spacing), profile=config.profile, savefolder=config.savefolder)