From 485bd79099d9a09dd4846e430a9838ee3fbe3764 Mon Sep 17 00:00:00 2001
From: Carsten Hinz <c.hinz@fz-juelich.de>
Date: Tue, 7 May 2024 10:26:56 +0200
Subject: [PATCH] added first documentation to benchmark script

removed extraction of a single day from benchmark -> seems to cause
crashes.

added output directories of benchmark script to ignore
---
 .gitignore         |  1 +
 tests/benchmark.py | 31 +++++++++++++++++++++++++++++--
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index 8922727..450b221 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 71fb5b4..635859c 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)),
-- 
GitLab