From d5f19eae06b85069bdb64139601da2cb48918890 Mon Sep 17 00:00:00 2001 From: Martin Lange <martin.lange@ufz.de> Date: Wed, 7 Dec 2022 16:25:56 +0100 Subject: [PATCH] run benchmarks only be file prefix --- benchmarks/profiling/mem_huge_memory.py | 39 +++++++++++++++++++ .../{simple_numpy.py => profile_numpy.py} | 0 benchmarks/run_profiling.sh | 13 ++++--- 3 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 benchmarks/profiling/mem_huge_memory.py rename benchmarks/profiling/{simple_numpy.py => profile_numpy.py} (100%) diff --git a/benchmarks/profiling/mem_huge_memory.py b/benchmarks/profiling/mem_huge_memory.py new file mode 100644 index 00000000..cbed59fc --- /dev/null +++ b/benchmarks/profiling/mem_huge_memory.py @@ -0,0 +1,39 @@ +import datetime as dt + +import numpy as np + +import finam as fm + +if __name__ == "__main__": + start_time = dt.datetime(2000, 1, 1) + end_time = dt.datetime(2002, 1, 1) + + size = (1024, 1024) + + info1 = fm.Info(time=None, grid=fm.UniformGrid(size), units="m") + data = fm.data.to_xarray(fm.data.full(0.0, info1), info1) + + + def gen_data(t): + return np.copy(data) + + + source = fm.modules.CallbackGenerator( + callbacks={"Out": (gen_data, info1.copy())}, + start=start_time, + step=dt.timedelta(days=1), + ) + sink = fm.modules.DebugConsumer( + inputs={ + "In": info1.copy(), + }, + start=start_time, + step=dt.timedelta(days=365), + ) + + composition = fm.Composition([source, sink]) + composition.initialize() + + source["Out"] >> sink["In"] + + composition.run(end_time=end_time) diff --git a/benchmarks/profiling/simple_numpy.py b/benchmarks/profiling/profile_numpy.py similarity index 100% rename from benchmarks/profiling/simple_numpy.py rename to benchmarks/profiling/profile_numpy.py diff --git a/benchmarks/run_profiling.sh b/benchmarks/run_profiling.sh index 1fdfe48b..789e8363 100755 --- a/benchmarks/run_profiling.sh +++ b/benchmarks/run_profiling.sh @@ -6,11 +6,14 @@ mkdir -p prof for filename in benchmarks/profiling/*.py; do fn=$(basename -- "$filename") fn="${fn%.*}" - echo "$fn" - python benchmarks/profiling/"$fn".py prof/"$fn".pstats - gprof2dot --colour-nodes-by-selftime -f pstats prof/"$fn".pstats > prof/"$fn".dot - dot -Tsvg -o prof/"$fn".svg prof/"$fn".dot - dot -Tpng -o prof/"$fn".png prof/"$fn".dot + if [[ "$fn" == profile_* ]] ; + then + echo "$fn" + python benchmarks/profiling/"$fn".py prof/"$fn".pstats + gprof2dot --colour-nodes-by-selftime -f pstats prof/"$fn".pstats > prof/"$fn".dot + dot -Tsvg -o prof/"$fn".svg prof/"$fn".dot + dot -Tpng -o prof/"$fn".png prof/"$fn".dot + fi done python benchmarks/pstats_to_csv.py -- GitLab