Delete unused function

This commit is contained in:
Shay Nehmad 2020-03-16 14:31:13 +02:00
parent 31c348d26a
commit 347941c776
2 changed files with 4 additions and 28 deletions

View File

@ -28,20 +28,16 @@ class PerformanceAnalyzer(Analyzer):
if not self.island_client.is_all_monkeys_dead(): if not self.island_client.is_all_monkeys_dead():
raise RuntimeError("Can't test report times since not all Monkeys have died.") raise RuntimeError("Can't test report times since not all Monkeys have died.")
total_time = timedelta() # Collect timings for all pages
self.island_client.clear_caches() self.island_client.clear_caches()
report_resource_to_response_time = {} report_resource_to_response_time = {}
for url in REPORT_URLS: for url in REPORT_URLS:
report_resource_to_response_time[url] = self.island_client.get_elapsed_for_get_request(url) report_resource_to_response_time[url] = self.island_client.get_elapsed_for_get_request(url)
timings = self.island_client.time_all_report_pages() # Calculate total time and check each page
single_page_time_less_then_max = True single_page_time_less_then_max = True
total_time = timedelta()
for page, elapsed in timings.items(): for page, elapsed in report_resource_to_response_time.items():
logger.info(f"page {page} took {str(elapsed)}") logger.info(f"page {page} took {str(elapsed)}")
total_time += elapsed total_time += elapsed
if elapsed > MAX_ALLOWED_SINGLE_PAGE_TIME: if elapsed > MAX_ALLOWED_SINGLE_PAGE_TIME:

View File

@ -97,26 +97,6 @@ class MonkeyIslandClient(object):
response.raise_for_status() response.raise_for_status()
return response return response
def time_all_report_pages(self):
"""
Calculates elapsed time of request for each report URL
Make sure to call clear_caches before this function if you want to measure "worst case" generation time.
"""
REPORT_URLS = [
"api/report/security",
"api/attack/report",
"api/report/zero_trust/findings",
"api/report/zero_trust/principles",
"api/report/zero_trust/pillars"
]
report_resource_to_response_time = {}
for url in REPORT_URLS:
report_resource_to_response_time[url] = self.get_elapsed_for_get_request(url)
return report_resource_to_response_time
def get_elapsed_for_get_request(self, url): def get_elapsed_for_get_request(self, url):
response = self.requests.get(url) response = self.requests.get(url)
if response.ok: if response.ok: