Skip to content

Commit 2cc806b

Browse files
committed
WIP, limpiando codigo, reorganizando y refactorizando
1 parent c700a2e commit 2cc806b

File tree

7 files changed

+135
-490
lines changed

7 files changed

+135
-490
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/REPORTS/*
2+
/src/timeseries_plots/
23
.pyc
34
**/__pycache__/**
45
.idea/
6+
conf/experiments/report_generator_config.ini

conf/experiments/blockchain/report_generator_config.ini

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ PRINT_MISSING_INFO_REPORT = true
55
PRINT_TEST_BASIC_INFORMATION = true
66

77
GENERATE_EXPERIMENT_PLOT = true
8-
GENERATE_USER_PLOTS = false
9-
GENERATE_APP_PLOTS = false
8+
GENERATE_USER_PLOTS = true
9+
GENERATE_APP_PLOTS = true
1010
GENERATE_NODES_PLOTS = true
1111

1212
NODES_LIST = "cont0"
13+
USERS_LIST = "user0"
1314

1415
STATIC_LIMITS = false
1516
REPORTED_RESOURCES = "cpu"

src/ExperimentReporter.py

+21-100
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@
2525
import sys
2626
import time
2727

28-
from src.lineplotting.lineplots import plot_document, plot_user
28+
from src.lineplotting.lineplots import plot_test, plot_user
2929
from src.common.config import Config, MongoDBConfig, eprint
3030

3131
from src.latex.latex_output import print_latex_section
3232
from src.TestReporter import TestReporter
3333
from TimestampsSnitch.src.mongodb.mongodb_agent import MongoDBTimestampAgent
34-
from src.common.utils import generate_duration, print_basic_doc_info, split_tests_by_test_type, \
35-
generate_resources_timeseries, get_plots
34+
from src.common.utils import generate_duration, print_basic_doc_info, generate_resources_timeseries, nowt
3635

3736

3837
class ExperimentReporter():
@@ -41,111 +40,38 @@ def __init__(self):
4140
mongoDBConfig = MongoDBConfig()
4241
self.timestampingAgent = MongoDBTimestampAgent(mongoDBConfig.get_config_as_dict())
4342

44-
def get_experiment_data(self, exp):
45-
exp = generate_duration(exp)
46-
exp = generate_resources_timeseries(exp, self.cfg)
47-
return exp
48-
49-
def print_experiment_report(self, exp):
50-
# PRINT EXPERIMENT INFO
51-
print_latex_section("Experiment basic information")
52-
print_basic_doc_info(exp)
53-
54-
def report_tests_serverless(self, processed_tests):
43+
def report_tests(self, processed_tests):
5544
testRepo = TestReporter()
5645

57-
# PRINT TESTS RESOURCE INFO
58-
# (durations with overheads, resource usages, utilization, overheads, hysteresis and basic each test info)
59-
benchmarks = split_tests_by_test_type(processed_tests)
60-
test_reports = [
61-
("Resource usages", testRepo.print_tests_resource_usage, [], True),
62-
("Tests durations", testRepo.print_tests_times, [], True),
63-
("Tests basic information", testRepo.print_test_report, [self.cfg.PRINT_NODE_INFO],
64-
self.cfg.PRINT_TEST_BASIC_INFORMATION),
65-
("Missing information report", testRepo.report_resources_missing_data, [],
66-
self.cfg.PRINT_MISSING_INFO_REPORT),
67-
("Resource utilization", testRepo.print_tests_resource_utilization, [], True),
68-
("Tests durations and overheads", testRepo.print_summarized_tests_info, [self.cfg.NUM_BASE_EXPERIMENTS],
69-
False),
70-
("Resource overheads", testRepo.print_tests_resource_overhead_report, [self.cfg.NUM_BASE_EXPERIMENTS],
71-
False and self.cfg.NUM_BASE_EXPERIMENTS != 0)]
72-
73-
for test_type in benchmarks:
74-
for report in test_reports:
75-
report_name, report_function, report_function_extra, bool_apply = report
76-
if bool_apply:
77-
eprint("Doing {0} for {1} at {2}".format(
78-
report_name, test_type, time.strftime("%D %H:%M:%S", time.localtime())))
79-
print_latex_section("{0} for {1}".format(report_name, test_type))
80-
args = tuple([benchmarks[test_type]] + report_function_extra)
81-
report_function(*args)
82-
83-
if self.cfg.GENERATE_APP_PLOTS or self.cfg.GENERATE_NODES_PLOTS:
84-
for test_type in benchmarks:
85-
eprint("Plotting resource plots for {0} at {1}".format(
86-
test_type, time.strftime("%D %H:%M:%S", time.localtime())))
87-
testRepo.generate_test_resource_plot(benchmarks[test_type])
88-
89-
def report_tests_energy(self, processed_tests):
90-
testRepo = TestReporter()
91-
# PRINT TESTS RESOURCE INFO
92-
# (durations with overheads, resource usages, utilization, overheads, hysteresis and basic each test info)
9346
test_reports = [
94-
("Resource usages", testRepo.print_tests_resource_usage, [], True),
95-
("Tests durations", testRepo.print_tests_times, [], True),
96-
("Tests basic information", testRepo.print_test_report, [self.cfg.PRINT_NODE_INFO],
97-
self.cfg.PRINT_TEST_BASIC_INFORMATION),
98-
("Missing information report", testRepo.report_resources_missing_data, [],
99-
self.cfg.PRINT_MISSING_INFO_REPORT),
100-
("Resource utilization", testRepo.print_tests_resource_utilization, [], True)]
47+
("Resource usages", testRepo.print_tests_resource_usage, True),
48+
("Tests durations", testRepo.print_tests_times, True),
49+
("Tests basic information", testRepo.print_test_report, self.cfg.PRINT_TEST_BASIC_INFORMATION),
50+
("Missing information report", testRepo.report_resources_missing_data, self.cfg.PRINT_MISSING_INFO_REPORT),
51+
("Resource utilization", testRepo.print_tests_resource_utilization, True),
52+
]
10153

10254
for report in test_reports:
103-
report_name, report_function, report_function_extra, bool_apply = report
55+
report_name, report_function, bool_apply = report
10456
if bool_apply:
105-
eprint("Doing {0} at {1}".format(
106-
report_name, time.strftime("%D %H:%M:%S", time.localtime())))
57+
eprint("Doing {0} at {1}".format(report_name, nowt()))
10758
print_latex_section("{0}".format(report_name))
108-
args = tuple([processed_tests] + report_function_extra)
109-
report_function(*args)
59+
report_function(processed_tests)
11060

11161
if self.cfg.GENERATE_APP_PLOTS or self.cfg.GENERATE_NODES_PLOTS:
62+
eprint("Plotting resource plots for at {0}".format(nowt()))
11263
testRepo.generate_test_resource_plot(processed_tests)
11364

114-
def report_experiment(self, exp):
65+
66+
def report_experiment(self, experiment):
11567
testRepo = TestReporter()
116-
report_type = self.cfg.EXPERIMENT_TYPE
11768

11869
# Get the timeseries and compute durations for the experiment
119-
experiment = self.get_experiment_data(exp)
120-
121-
# Print the basic experiment info
122-
eprint("Generating experiment info at {0}".format(time.strftime("%D %H:%M:%S", time.localtime())))
123-
self.print_experiment_report(experiment)
124-
125-
if self.cfg.GENERATE_EXPERIMENT_PLOT:
126-
if "end_time" not in experiment or "start_time" not in experiment:
127-
return
128-
129-
eprint("Plotting experiment {0}".format(time.strftime("%D %H:%M:%S", time.localtime())))
130-
start, end = experiment["start_time"], experiment["end_time"]
131-
plots = get_plots()
132-
133-
if self.cfg.GENERATE_NODES_PLOTS:
134-
for node in self.cfg.NODES_LIST:
135-
test_plots = plots["node"][report_type]
136-
structure = (node, "node")
137-
plot_document(experiment, structure, test_plots, start, end, self.cfg.REPORTED_RESOURCES)
138-
139-
if self.cfg.GENERATE_APP_PLOTS:
140-
for app in self.cfg.APPS_LIST + ["ALL"]:
141-
app_plots = plots["app"][report_type]
142-
structure = (app, "app")
143-
plot_document(experiment, structure, app_plots, start, end, self.cfg.REPORTED_RESOURCES)
144-
145-
if self.cfg.GENERATE_USER_PLOTS:
146-
for user in self.cfg.USERS_LIST:
147-
user_plots = plots["user"][report_type]
148-
plot_user(experiment, user, user_plots, start, end, self.cfg.REPORTED_RESOURCES)
70+
eprint("Generating experiment info at {0}".format(nowt()))
71+
experiment = generate_duration(experiment)
72+
experiment = generate_resources_timeseries(experiment, self.cfg)
73+
print_latex_section("Experiment basic information")
74+
print_basic_doc_info(experiment)
14975

15076
# Get the experiment tests
15177
tests = self.timestampingAgent.get_experiment_tests(experiment["experiment_id"], experiment["username"])
@@ -154,9 +80,4 @@ def report_experiment(self, exp):
15480
processed_tests = list(testRepo.get_test_data(test) for test in tests)
15581

15682
# Print the basic tests info
157-
if report_type == "serverless":
158-
self.report_tests_serverless(processed_tests)
159-
elif report_type == "energy":
160-
self.report_tests_energy(processed_tests)
161-
else:
162-
pass
83+
self.report_tests(processed_tests)

src/TestReporter.py

+12-118
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,15 @@
2323

2424
from __future__ import print_function
2525

26-
import sys
2726

2827
from src.opentsdb import bdwatchdog
2928
from src.common.config import Config, OpenTSDBConfig, eprint
3029
from src.latex.latex_output import latex_print, print_latex_stress
3130

32-
from src.barplotting.barplots import plot_tests_resource_usage, plot_tests_times
33-
from src.lineplotting.lineplots import plot_document
31+
from src.lineplotting.lineplots import plot_test
3432

3533
from src.common.utils import generate_duration, translate_metric, format_metric, flush_table, \
36-
print_basic_doc_info, generate_resources_timeseries, get_plots
34+
print_basic_doc_info, generate_resources_timeseries, get_plots_metrics
3735

3836

3937
class TestReporter:
@@ -55,19 +53,22 @@ def generate_test_resource_plot(self, tests):
5553
return
5654

5755
start, end = test["start_time"], test["end_time"]
58-
plots = get_plots()
56+
plots = get_plots_metrics()
5957

6058
if self.cfg.GENERATE_NODES_PLOTS:
6159
for node in self.cfg.NODES_LIST:
6260
test_plots = plots["node"][report_type]
63-
structure = (node, "node")
64-
plot_document(test, structure, test_plots, start, end, self.cfg.REPORTED_RESOURCES)
61+
plot_test(test, node, "node", test_plots, start, end, self.cfg.REPORTED_RESOURCES)
6562

6663
if self.cfg.GENERATE_APP_PLOTS:
6764
for app in self.cfg.APPS_LIST + ["ALL"]:
6865
app_plots = plots["app"][report_type]
69-
structure = (app, "app")
70-
plot_document(test, structure, app_plots, start, end, self.cfg.REPORTED_RESOURCES)
66+
plot_test(test, app, "app", app_plots, start, end, self.cfg.REPORTED_RESOURCES)
67+
68+
if self.cfg.GENERATE_USER_PLOTS:
69+
for user in self.cfg.USERS_LIST + ["ALL"]:
70+
user_plots = plots["user"][report_type]
71+
plot_test(test, user, "user", user_plots, start, end, self.cfg.REPORTED_RESOURCES)
7172

7273
# PRINT TEST RESOURCE USAGES
7374
def print_test_resources(self, test, structures_list):
@@ -111,59 +112,6 @@ def flush_rows_with_aggregations(self, rows, headers, table_caption=None):
111112
final_rows += list(rows[row].values())
112113
flush_table(final_rows, headers, table_caption)
113114

114-
# PRINT TEST RESOURCE OVERHEAD
115-
def print_tests_resource_overhead_report(self, tests, num_base_experiments=3, print_with_stepping=True):
116-
table_caption = "TESTs resource overhead"
117-
max_columns = self.cfg.MAX_COLUMNS["print_tests_resource_overhead_report"]
118-
resource_tuples = self.cfg.METRICS_FOR_OVERHEAD_REPORT
119-
120-
overheads, base_values, headers, num_columns, remaining_data = dict(), dict(), ["resource"], 0, False
121-
122-
for test in tests[:num_base_experiments]:
123-
headers.append(test["test_name"])
124-
for resource_tuple in resource_tuples:
125-
resource, usage_metric = resource_tuple
126-
if resource not in overheads:
127-
overheads[resource] = [resource]
128-
base_values[resource] = 0
129-
130-
if test["resource_aggregates"] != "n/a":
131-
overheads[resource].append("---")
132-
base_values[resource] += test["resource_aggregates"]["ALL"][usage_metric]["SUM"]
133-
else:
134-
overheads[resource].append("n/a")
135-
for resource in base_values:
136-
base_values[resource] = base_values[resource] / num_base_experiments
137-
138-
num_columns += num_base_experiments
139-
140-
for test in tests[num_base_experiments:]:
141-
headers.append(test["test_name"])
142-
for resource_tuple in resource_tuples:
143-
resource, usage_metric = resource_tuple
144-
145-
if resource not in overheads:
146-
overheads[resource] = [resource]
147-
148-
if test["resource_aggregates"] != "n/a":
149-
overhead = test["resource_aggregates"]["ALL"][usage_metric]["SUM"] / base_values[resource]
150-
resource_overhead = str(int((overhead - 1) * 100)) + "%"
151-
else:
152-
resource_overhead = "n/a"
153-
154-
overheads[resource].append(resource_overhead)
155-
156-
num_columns += 1
157-
remaining_data = True
158-
if num_columns >= max_columns:
159-
flush_table(overheads.values(), headers, table_caption)
160-
table_caption = None
161-
overheads, headers, num_columns, remaining_data = dict(), ["resource"], 0, False
162-
if remaining_data:
163-
flush_table(overheads.values(), headers, table_caption)
164-
165-
plot_tests_resource_usage(tests)
166-
167115
# PRINT TEST RESOURCE UTILIZATION
168116
def print_tests_resource_utilization(self, tests):
169117
max_columns = self.cfg.MAX_COLUMNS["print_tests_resource_utilization_report"]
@@ -296,7 +244,8 @@ def print_tests_resource_usage(self, tests):
296244
if remaining_data:
297245
self.flush_rows_with_aggregations(rows, headers, table_caption)
298246

299-
def print_test_report(self, tests, print_node_info):
247+
def print_test_report(self, tests):
248+
print_node_info = self.cfg.PRINT_NODE_INFO
300249
# PRINT BASIC INFO ABOUT THE TEST
301250
for test in tests:
302251
print_basic_doc_info(test)
@@ -340,58 +289,3 @@ def print_tests_times(self, tests):
340289

341290
if remaining_data:
342291
flush_table([durations_seconds, durations_minutes], headers, table_caption)
343-
344-
def print_summarized_tests_info(self, tests, num_base_experiments, print_with_stepping=True):
345-
max_columns = self.cfg.MAX_COLUMNS["print_summarized_tests_info"]
346-
table_caption = "TESTs durations and time benchmarking (over the first {0} experiments)".format(
347-
num_base_experiments)
348-
349-
headers, overheads, durations_seconds, durations_minutes, num_columns, remaining_data = \
350-
["time"], ["overhead"], ["seconds"], ["minutes"], 0, False
351-
basetime = 0
352-
353-
if num_base_experiments == 0:
354-
basetime = 1
355-
else:
356-
for test in tests[:num_base_experiments]:
357-
headers.append(test["test_name"])
358-
basetime += test["duration"]
359-
overheads.append("---")
360-
durations_seconds.append(test["duration"])
361-
durations_minutes.append("{:.2f}".format((test["duration"]) / 60))
362-
363-
num_columns += 1
364-
remaining_data = True
365-
if num_columns >= max_columns:
366-
flush_table([durations_seconds, durations_minutes, overheads], headers, table_caption)
367-
table_caption = None
368-
headers, overheads, durations_seconds, durations_minutes, num_columns, remaining_data = \
369-
["time"], ["overhead"], ["seconds"], ["minutes"], 0, False
370-
371-
basetime = basetime / num_base_experiments
372-
373-
for test in tests[num_base_experiments:]:
374-
headers.append(test["test_name"])
375-
seconds, minutes, overhead = "n/a", "n/a", "n/a"
376-
if test["duration"] != "n/a":
377-
seconds = test["duration"]
378-
minutes = "{:.2f}".format((test["duration"]) / 60)
379-
overhead = test["duration"] / basetime
380-
overhead = str(int((overhead - 1) * 100)) + "%"
381-
382-
durations_seconds.append(seconds)
383-
durations_minutes.append(minutes)
384-
overheads.append(overhead)
385-
386-
num_columns += 1
387-
remaining_data = True
388-
if num_columns >= max_columns:
389-
flush_table([durations_seconds, durations_minutes, overheads], headers, table_caption)
390-
table_caption = None
391-
headers, overheads, durations_seconds, durations_minutes, num_columns, remaining_data = \
392-
["time"], ["overhead"], ["seconds"], ["minutes"], 0, False
393-
394-
if remaining_data:
395-
flush_table([durations_seconds, durations_minutes, overheads], headers, table_caption)
396-
397-
plot_tests_times(tests)

0 commit comments

Comments
 (0)