Skip to content

Commit

Permalink
price perf
Browse files Browse the repository at this point in the history
  • Loading branch information
sousinha1997 committed Aug 22, 2024
1 parent 061e6aa commit 0e7097d
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 30 deletions.
3 changes: 3 additions & 0 deletions health_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,6 @@ def health_check():
check_virtual_environment()
check_python_version()
check_and_install_requirements()

if __name__ == "__main__":
health_check()
37 changes: 33 additions & 4 deletions quisby/benchmarks/phoronix/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,30 @@
get_sheet,
create_sheet, clear_sheet_data, clear_sheet_charts,
)
from quisby.util import merge_lists_alternately
from quisby.util import merge_lists_alternately,read_config
import re

def extract_prefix_and_number(input_string):
match = re.search(r'^(.*?)(\d+)(.*?)$', input_string)
if match:
prefix = match.group(1)
return prefix
return None

def compare_phoronix_results(spreadsheets, spreadsheetId, test_name, table_name=["SYSTEM_NAME"]):

def compare_inst(item1, item2):
cloud_type = read_config("cloud", "cloud_type")
if cloud_type == "localhost":
return True
elif cloud_type == "aws":
return item1.split(".")[0] == item2.split(".")[0]
elif cloud_type == "gcp":
return item1.split("-")[0], item2.split("-")[0]
elif cloud_type == "azure":
return extract_prefix_and_number(item1) == extract_prefix_and_number(item2)


def compare_phoronix_results(spreadsheets, spreadsheetId, test_name, table_name=["System name", "Price/perf"]):
values = []
results = []
spreadsheet_name = []
Expand All @@ -28,14 +48,23 @@ def compare_phoronix_results(spreadsheets, spreadsheetId, test_name, table_name=
for value in list_1:
for ele in list_2:
# Check max throughput
if value[0][0] in table_name and ele[0][0] in table_name:
if value[0][0] in table_name and ele[0][0] in table_name and value[0][0] == ele[0][0]:
results.append([""])
for item1 in value:
for item2 in ele:
if item1[0] == item2[0]:
results = merge_lists_alternately(results, item1, item2)
break

elif value[0][0] == "Cost/Hr" and ele[0][0] == "Cost/Hr":
if compare_inst(value[1][0], ele[1][0]):
results.append([""])
for item1 in value:
for item2 in ele:
if item1[0] == item2[0]:
results.append(item1)
break

elif value[1][0] == ele[1][0]:
if value[0][0] == ele[0][0]:
results.append([""])
Expand Down Expand Up @@ -66,4 +95,4 @@ def compare_phoronix_results(spreadsheets, spreadsheetId, test_name, table_name=
test_name = "phoronix"

graph_phoronix_data(spreadsheets, "", test_name,
table_name=["SYSTEM_NAME"])
table_name=["SYSTEM_NAME"])
45 changes: 37 additions & 8 deletions quisby/benchmarks/phoronix/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,18 @@ def graph_phoronix_data(spreadsheetId, range, action):

for index, row in enumerate(data):
for col in row:
if "GEOMEAN" in col:
if "System name" in col:
start_index = index
title = "%s : %s" % (range, "Geomean")
subtitle=""
elif "Price/perf" in row:
start_index = index
title = "%s : %s" % (range, "Price-Performance")
subtitle = "Geomean/$"

if start_index:
if not row:
end_index = index - 1
end_index = index
if index + 1 == len(data):
end_index = index + 1

Expand All @@ -126,17 +133,36 @@ def graph_phoronix_data(spreadsheetId, range, action):
"addChart": {
"chart": {
"spec": {
"title": "%s : %s" % (range, "GEOMEAN"),
"title": title,
"subtitle": subtitle,
"basicChart": {
"chartType": "COMBO",
"legendPosition": "BOTTOM_LEGEND",
"legendPosition": "RIGHT_LEGEND",
"axis": [
{"position": "BOTTOM_AXIS", "title": ""},
{
"format": {
"bold": True,
"italic": True,
"fontSize": 14
},
"position": "BOTTOM_AXIS",
"title": "System"
},
{
"format": {
"bold": True,
"italic": True,
"fontSize": 14
},
"position": "LEFT_AXIS",
"title": "Geomean",
"title": graph_data[0][1].lower(),
},
{
"format": {
"bold": True,
"italic": True,
"fontSize": 14
},
"position": "RIGHT_AXIS",
"title": "%Diff",
},
Expand Down Expand Up @@ -168,7 +194,10 @@ def graph_phoronix_data(spreadsheetId, range, action):
"sheetId": sheetId,
"rowIndex": GRAPH_ROW_INDEX,
"columnIndex": column_count + GRAPH_COL_INDEX,
}
},
"offsetXPixels": 100,
"widthPixels": 600,
"heightPixels": 400
}
},
}
Expand All @@ -195,4 +224,4 @@ def graph_phoronix_data(spreadsheetId, range, action):
if not threshold:
threshold = "5"
for col in diff_col:
update_conditional_formatting(spreadsheetId, sheetId, col, threshold)
update_conditional_formatting(spreadsheetId, sheetId, col, threshold)
71 changes: 53 additions & 18 deletions quisby/benchmarks/phoronix/phoronix.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@

from quisby import custom_logger
from quisby.util import read_config
import re


def extract_prefix_and_number(input_string):
match = re.search(r'^(.*?)(\d+)(.*?)$', input_string)
if match:
prefix = match.group(1)
number = int(match.group(2))
suffix = match.group(3)
return prefix, number, suffix
return None, None, None
from quisby.pricing.cloud_pricing import get_cloud_pricing


def custom_key(item):
Expand All @@ -27,9 +17,21 @@ def custom_key(item):
instance_type = item[0].split("-")[0]
instance_number = int(item[0].split('-')[-1])
return instance_type, instance_number
elif cloud_type == "azure":
instance_type, instance_number, version=extract_prefix_and_number(item[0])
return (instance_type, instance_number)


def calc_price_performance(inst, avg):
region = read_config("cloud", "region")
cloud_type = read_config("cloud", "cloud_type")
os_type = read_config("test", "os_type")
cost_per_hour = None
try:
cost_per_hour = get_cloud_pricing(
inst, region, cloud_type.lower(), os_type)
price_perf = float(avg)/float(cost_per_hour)
except Exception as exc:
custom_logger.debug(str(exc))
custom_logger.error("Error calculating value !")
return cost_per_hour, price_perf


def create_summary_phoronix_data(data, OS_RELEASE):
Expand All @@ -40,11 +42,21 @@ def create_summary_phoronix_data(data, OS_RELEASE):
end_index = 0
start_index = 0
system = ""
cost_per_hour, price_per_perf = [], []
# Add summary data
for index, row in enumerate(data):
if row == [""]:
if processed_data:
SYSTEM_GEOMEAN.append([system, gmean(gmean_data)])
inst = processed_data[0]
gdata = gmean(gmean_data)
SYSTEM_GEOMEAN.append([system, gdata])
try:
cph, pp = calc_price_performance(inst, gdata)
except Exception as exc:
custom_logger.error(str(exc))
continue
price_per_perf.append([inst, pp])
cost_per_hour.append([inst, cph])
processed_data = []
gmean_data = []
system = ""
Expand All @@ -57,10 +69,33 @@ def create_summary_phoronix_data(data, OS_RELEASE):
start_index = 0
elif end_index:
gmean_data.append(float(row[1]))
SYSTEM_GEOMEAN.append([system, gmean(gmean_data)])
if processed_data:
cph = 0
pp = 0
inst = processed_data[0]
gdata = gmean(gmean_data)
SYSTEM_GEOMEAN.append([system, gdata])
try:
cph, pp = calc_price_performance(inst, gdata)
except Exception as exc:
custom_logger.error(str(exc))
price_per_perf.append([inst, pp])

cost_per_hour.append([inst, cph])

results.append([""])
results.append(["SYSTEM_NAME", "GEOMEAN-" + str(OS_RELEASE)])
results.append(["System name", "Geomean-" + str(OS_RELEASE)])
sorted_data = sorted(SYSTEM_GEOMEAN, key=custom_key)
for item in sorted_data:
results.append(item)
results.append([""])
results.append(["Cost/Hr"])
sorted_data = sorted(cost_per_hour, key=custom_key)
for item in sorted_data:
results.append(item)
results.append([""])
results.append(["Price/perf", f"Geomean/$-{OS_RELEASE}"])
sorted_data = sorted(price_per_perf, key=custom_key)
for item in sorted_data:
results.append(item)
return results
Expand All @@ -85,4 +120,4 @@ def extract_phoronix_data(path, system_name, OS_RELEASE):
results.append([""])
results.append([system_name])
results.extend(phoronix_results[1:])
return results
return results

0 comments on commit 0e7097d

Please sign in to comment.