Skip to content

Commit 11ce220

Browse files
CI: Add inference benchmark (#666)
1 parent ab2681e commit 11ce220

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

asv_bench/benchmarks/inference.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import numpy as np
2+
3+
import pysindy as ps
4+
5+
6+
class InferenceBM:
7+
"""
8+
An example benchmark that times the performance of various kinds
9+
of iterating over dictionaries in Python.
10+
"""
11+
12+
def setup(self):
13+
t = np.linspace(0, 1, 100)
14+
x = 3 * np.exp(-2 * t)
15+
y = 0.5 * np.exp(t)
16+
X = np.stack((x, y), axis=-1) # First column is x, second is y
17+
18+
self.model = ps.SINDy()
19+
self.model.fit(X, t=t, feature_names=["x", "y"])
20+
rng = np.random.default_rng(42)
21+
self.inputs = rng.random((1000, 2))
22+
23+
def time_a_predict(self):
24+
self.model.predict(self.inputs[:1])
25+
26+
def peakmem_a_predict(self):
27+
self.model.predict(self.inputs[:1])
28+
29+
def time_batch_predict(self):
30+
self.model.predict(self.inputs)
31+
32+
def peakmem_batch_predict(self):
33+
self.model.predict(self.inputs)

0 commit comments

Comments
 (0)