From 8e775c189fe48fb1b638c91751d307ff07e569bf Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Mon, 4 Jul 2022 05:56:06 +0000 Subject: [PATCH] Add test file --- apiserver/test.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 apiserver/test.py diff --git a/apiserver/test.py b/apiserver/test.py new file mode 100644 index 0000000..2f831fe --- /dev/null +++ b/apiserver/test.py @@ -0,0 +1,23 @@ +import time +import requests + +def test_search_api(): + num_tests = 100 + total_time = 0 + + for i in range(num_tests): + start = time.time() + + res = requests.get('http://127.0.0.1:33842/api/search?q=iphone') + res.raise_for_status() + + duration = time.time() - start + total_time += duration + + avg_time = total_time / num_tests + + print('Average search time:', avg_time) + + +if __name__ == '__main__': + test_search_api()