-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speed up search by avoiding the creation of intermediary objects #162
Speed up search by avoiding the creation of intermediary objects #162
Conversation
Signed-off-by: Ahmad Wahid <[email protected]>
Signed-off-by: Ahmad Wahid <[email protected]>
Signed-off-by: Ahmad Wahid <[email protected]>
Signed-off-by: Ahmad Wahid <[email protected]>
Signed-off-by: Ahmad Wahid <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
…' into feature/search-avoids-creating-TimedBelief-objects
Signed-off-by: F.N. Claessen <[email protected]>
… the source kwarg in case that is passed Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
… used whatever was passed in the DataFrame, which was belief_horizon, so we need to convert Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
…-creating-TimedBelief-objects
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Awesome!! I created a small benchmark where I compare the speed of fetching the beliefs of 200 sensors that I have in my DB. The average improvement is of Two observations:
from flexmeasures.app import create
from flexmeasures.data.models.time_series import TimedBelief
from flexmeasures.data.models.time_series import Sensor
from flexmeasures.data.models.time_series import TimedBelief
app = create()
import time
FILENAME ="old.txt"
with app.app_context():
sensors = Sensor.query.all()[:200]
with open(FILENAME, "w+") as f:
try:
for sensor in sensors:
t = time.process_time()
TimedBelief.search_session(app.db.session, sensor)
t1 = time.process_time() - t
print(t1)
f.write(str(t1) + "\n")
f.flush()
except KeyboardInterrupt:
pass
|
@Ahmad-Wahid in our private meeting you mentioned a flexmeasures issue that was related to this PR, and that you posted relevant info on GitHub. Can you point me to it? Maybe it was this one, but it doesn't seem related to me. |
I'm trying to skip having the ORM create a potentially large number of
TimedBelief
objects.