Skip to content

Commit 051369d

Browse files
authored
Merge pull request #38 from LSSTDESC/fix_benchmarks_push
Add memory benchmarks
2 parents 06c1a25 + 9517ab5 commit 051369d

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

benchmarks/benchmarks.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def time_feature_creation():
2727
feature_extractor="malanchev"
2828
)
2929

30+
3031
def time_learn_loop(ml_model, strategy):
3132
"""Benchmark how long it takes for a run of the learning loop."""
3233
# Use the precomputed features so we don't time their creation.
@@ -54,3 +55,29 @@ def time_learn_loop(ml_model, strategy):
5455
["RandomForest", "KNN"], # The different ML methods
5556
["RandomSampling", "UncSampling"], # The different strategies.
5657
]
58+
59+
60+
def peakmem_learn_loop(ml_model):
61+
"""Benchmark how much memory it takes for a run of the learning loop."""
62+
# Use the precomputed features so we don't time their creation.
63+
features_file = str(_TEST_DATA_DIR / "test_features.csv")
64+
with tempfile.TemporaryDirectory() as dir_name:
65+
metrics_file = str(Path(dir_name) / "metrics.csv")
66+
output_queried_file = str(Path(dir_name) / "queried.csv")
67+
learn_loop(
68+
nloops=25,
69+
features_method="malanchev",
70+
classifier=ml_model,
71+
strategy="RandomSampling",
72+
path_to_features=features_file,
73+
output_metrics_file=metrics_file,
74+
output_queried_file=output_queried_file,
75+
training="original",
76+
batch=1,
77+
)
78+
79+
80+
# Parameterize the ML models and strategies we benchmark.
81+
peakmem_learn_loop.params = [
82+
["RandomForest", "KNN"], # The different ML methods
83+
]

0 commit comments

Comments
 (0)