Skip to content
Snippets Groups Projects
Commit ede3c38e authored by Martin Lange's avatar Martin Lange
Browse files

add a profiling job to the CI

parent 1e7f925e
No related branches found
No related tags found
1 merge request!221Benchmark full run, profiling
......@@ -50,6 +50,7 @@ coverage.xml
*.cover
.hypothesis/
/bench/
/prof/
# Translations
*.mo
......
......@@ -40,6 +40,19 @@ benchmark:
paths:
- bench
profile:
stage: test
before_script:
- apt-get update -y
- apt-get install -y graphviz
- pip3 install graphviz gprof2dot
script:
- pip3 install --editable .[test]
- ./benchmarks/run_profiling.sh
artifacts:
paths:
- prof
doctest:
stage: test
script:
......
import datetime as dt
import finam as fm
def run_model():
start_time = dt.datetime(2000, 1, 1)
end_time = dt.datetime(2000, 12, 31)
counter = 0
size = (128, 64)
info1 = fm.Info(time=None, grid=fm.UniformGrid(size), units="m")
info2 = fm.Info(time=None, grid=fm.UniformGrid(size), units="m")
data = [
fm.data.full(0.0, "input", info1, start_time),
fm.data.full(0.0, "input", info1, start_time),
]
def gen_data(t):
nonlocal counter
d = data[counter % 2]
counter += 1
d = fm.data.assign_time(d, t)
return d
source = fm.modules.CallbackGenerator(
callbacks={"Out": (gen_data, info1.copy())},
start=start_time,
step=dt.timedelta(days=1),
)
sink = fm.modules.DebugConsumer(
inputs={
"In": info2.copy(),
},
start=start_time,
step=dt.timedelta(days=1),
)
composition = fm.Composition([source, sink])
composition.initialize()
source["Out"] >> sink["In"]
composition.run(end_time=end_time)
if __name__ == "__main__":
for i in range(10):
run_model()
echo TEST
mkdir -p prof
python -m cProfile -o prof/simple_run.pstats benchmarks/profiling/simple_run.py
gprof2dot --colour-nodes-by-selftime -f pstats prof/simple_run.pstats > prof/simple_run.dot
dot -Tsvg -o prof/simple_run.svg prof/simple_run.dot
dot -Tpng -o prof/simple_run.png prof/simple_run.dot
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment