forked from ItziModel/itzi
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbenchmark_tutorial.py
More file actions
36 lines (28 loc) · 1.12 KB
/
benchmark_tutorial.py
File metadata and controls
36 lines (28 loc) · 1.12 KB
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
"""Benchmark for the tutorial simulation."""
import os
import pytest
from itzi import SimulationRunner
from itzi.configreader import ConfigReader
from itzi.profiler import profile_context
from tests.grass_tests.test_tutorial import ( # noqa: F401
itzi_tutorial,
grass_tutorial_session,
tutorial_test_file,
)
def run_simulation(config_file, test_data_temp_path):
"""The function to benchmark.
This function runs the tutorial simulation.
"""
profile_path = os.path.join(test_data_temp_path, "tutorial_profile.txt")
with profile_context(profile_path):
conf_data = ConfigReader(config_file)
sim_runner = SimulationRunner()
sim_runner.initialize(conf_data)
sim_runner.run().finalize()
@pytest.mark.usefixtures("itzi_tutorial")
def test_benchmark_tutorial(benchmark, test_data_path, test_data_temp_path):
"""Run the benchmark for the tutorial"""
os.environ["GRASS_OVERWRITE"] = "1"
config_file = os.path.join(test_data_path, "tutorial_files", "tutorial.ini")
# benchmark the run_simulation function
benchmark(run_simulation, config_file, test_data_temp_path)