Skip to content

Commit

Permalink
Update perf_format_converter.py
Browse files Browse the repository at this point in the history
  • Loading branch information
calebbiggers committed Nov 20, 2024
1 parent 8f36568 commit e55d690
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions scripts/perf_format_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ def get_expression(self, metric, platform):
# Replace event/const aliases with names
expression = base_formula.lower()
for event in events:
reg = r"((?<=[\s+\-*\/\(\)])|(?<=^))({})((?=[\s+\-*\/\(\)])|(?=$))".format(event["Alias"].lower())
reg = r"((?<=[\s+\-*\/\(\)])|(?<=^))({})((?=[\s+\-*\/\(\)\[])|(?=$))".format(event["Alias"].lower())
expression = re.sub(reg,
pad(self.translate_metric_event(event["Name"], platform)),
self.translate_metric_event(event["Name"], platform),
expression)
for const in constants:
reg = r"((?<=[\s+\-*\/\(\)])|(?<=^))({})((?=[\s+\-*\/\(\)])|(?=$))".format(const["Alias"].lower())
Expand Down Expand Up @@ -384,13 +384,17 @@ def get_brief_description(self, metric):

# Get only first sentence
if description.count(". ") > 1:
description = description.split(". ")[0] + ". "
description = description.split(". ")[0]
elif description.count(". ") == 1 and description.strip().endswith("."):
description = description.strip()
elif description.count(". ") == 1 and not description.strip().endswith("."):
description = description.split(". ")[0] + ". "
description = description.split(". ")[0]
else:
description = description.strip() + "."
description = description.strip()

# Remove ending period
if description.endswith("."):
description = description[0:-1]

return description.replace("ie:", "i.e.").strip()

Expand Down Expand Up @@ -441,7 +445,7 @@ def translate_metric_event(self, event_name, platform):
return self.translate_event_options(split, row)
print("[ERROR] - Event with no option translations: " + event_name)

return event_name
return event_name.replace("RXL", "RxL")


def translate_event_options(self, split, event_info):
Expand Down Expand Up @@ -589,7 +593,9 @@ def get_threshold(self, metric):
return fixPercentages(self.clean_metric_names(threshold))
else:
return self.clean_metric_names(threshold)

elif "Formula" in metric["Threshold"]:
threshold = metric["Threshold"]["Formula"].replace("&&", "&").replace("||", "|")
return self.clean_metric_names(threshold)

def clean_metric_names(self, formula):
return re.sub(r'\([^\(\)]+\)', "", formula).lower().replace("metric_","").replace("..", "")
Expand Down

0 comments on commit e55d690

Please sign in to comment.