diff --git a/.gitignore b/.gitignore index 892272791757702b6949054ee329750a82df0f4b..450b221944f0a911fb8bae441e04d4fdd4ecb7de 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ tests/cache/ tests/data/ data/ tests/results +tests/temp_data_cache/ diff --git a/tests/benchmark.py b/tests/benchmark.py index 71fb5b4e2ea2f4629c91adfe1db621952483a6ad..635859c21b73ca090f9d9ef343eaf2bc61970a5b 100644 --- a/tests/benchmark.py +++ b/tests/benchmark.py @@ -1,4 +1,20 @@ from datetime import datetime, timedelta +""" + +Script for benchmarking the performance of the TOAR Database. + +The script relies on the AnalysisServiceDownload for downloading the requested data. +For a subsequent request, the already downloaded data are not considered. + +The script contains two ways to access the databse: +- a manual way without downloading the data (not used) +- usage of the AnalysisService created for this module + +The output of this script are the durations of the requests. Each call is ended with the duration for this interval. +Meanwhile, the status outputs of the analysis service are given. +""" + + import time import requests from pathlib import Path @@ -79,7 +95,18 @@ def wait_for_client_response(client, sample): print(f"time out after 30min, try {half_hours+1}") -def time_rest_client_response(start, end): +def time_rest_client_response(start :datetime, end:datetime): + """benchmark function using the AnalysisService with download of the requested data + + Parameters: + ---------- + start: + start time point + end: + end time point + Results: + Prints duration and number of tries, i.e. number of calls of get_data, which times out after 30min. + """ print(f"starting request for {start}-{end}") path_cache = TEST_ROOT / "temp_data_cache" @@ -106,7 +133,7 @@ def time_rest_client_response(start, end): if __name__ == "__main__": time_windows = [ - (datetime(2010, 1, 1), datetime(2010, 1, 2)), + #(datetime(2010, 1, 1), datetime(2010, 1, 2)),#this line seems to cause crashes (datetime(2010, 1, 1), datetime(2010, 1, 8)), (datetime(2010, 1, 1), datetime(2010, 1, 31)), (datetime(2010, 1, 1), datetime(2010, 12, 31)),