1
# This file is part of MAUS: http://micewww.pp.rl.ac.uk:8080/projects/maus
3
# MAUS is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation, either version 3 of the License, or
6
# (at your option) any later version.
8
# MAUS is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with MAUS. If not, see <http://www.gnu.org/licenses/>.
17
Get tracking speed as a function of n_spills
26
MAUS_ROOT_DIR = os.getenv("MAUS_ROOT_DIR")
27
TMP_PATH = os.path.join(MAUS_ROOT_DIR, "tmp")
28
SIM_PATH = os.path.join(MAUS_ROOT_DIR, "bin", "simulate_mice.py")
29
TEST_PATH = os.path.join(MAUS_ROOT_DIR,
30
"tests/integration/test_simulation/test_tracking_speed")
32
class TestTrackingSpeed(unittest.TestCase): # pylint: disable=R0904
34
Test class to check tracking speed
37
def test_tracking_speed(self): # pylint: disable=R0201
39
Run simulation and time execution time.
41
log = open(TMP_PATH+'/test_tracking_speed.log', 'w')
42
out = open(TMP_PATH+'/test_tracking_speed.json', 'w')
45
config = os.path.join(TEST_PATH, 'configuration.py')
47
for n_spills in [0, 1, 5, 10, 50]:
48
time_start = time.time()
49
subproc = subprocess.Popen([
51
'--configuration_file', config,
52
'--spill_generator_number_of_spills', str(n_spills)],
53
stdout = log, stderr=subprocess.STDOUT)
54
subproc.wait() # pylint: disable=E1101
55
print "Took", time.time() - time_start, "seconds to track", \
56
n_spills, "spills each with 10 muons"
57
results.append({"dt":time.time()-time_start, "n_spills":n_spills})
58
out.write(json.dumps(results))
61
if __name__ == "__main__":