Skip to content

Commit

Permalink
Fix improvement message
Browse files Browse the repository at this point in the history
  • Loading branch information
gjulianm committed Dec 11, 2024
1 parent c239913 commit cf3a807
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tasks/ebpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ def _try_delete_github_comment(msg: str):

current_branch_artifacts_path = Path(current_branch_artifacts_path)
complexity_files = list(current_branch_artifacts_path.glob("verifier-complexity-*.tar.gz"))
print(complexity_files)
if len(complexity_files) == 0:
_try_delete_github_comment(
f"No complexity data found for the current branch at {current_branch_artifacts_path}"
Expand Down Expand Up @@ -804,6 +805,7 @@ def _try_delete_github_comment(msg: str):
max_complexity_abs_change = -9e9
threshold_for_max_limit = 0.85
programs_now_below_limit, programs_now_above_limit = 0, 0
has_programs_with_changes = False
for program, entries in sorted(program_complexity.items(), key=lambda x: max(e[2] for e in x[1])):
avg_new_complexity, avg_old_complexity = 0, 0
highest_new_complexity, highest_old_complexity = 0, 0
Expand Down Expand Up @@ -833,8 +835,11 @@ def _try_delete_github_comment(msg: str):
programs_now_above_limit += 1

abs_change = new_complexity - old_complexity
max_complexity_rel_change = max(max_complexity_rel_change, abs_change / old_complexity)
max_complexity_abs_change = max(max_complexity_abs_change, abs_change)

if abs_change != 0:
max_complexity_rel_change = max(max_complexity_rel_change, abs_change / old_complexity)
max_complexity_abs_change = max(max_complexity_abs_change, abs_change)
has_programs_with_changes = True

avg_new_complexity /= len(entries)
avg_old_complexity /= len(entries)
Expand All @@ -854,6 +859,12 @@ def _try_delete_github_comment(msg: str):
]
summarized_complexity_changes.append(row)

# Reset the max values if we have no programs with changes, as we don't want the -9e9 values
# which are used as the initial values
if not has_programs_with_changes:
max_complexity_abs_change = 0
max_complexity_rel_change = 0

headers = ["Program", "Avg. complexity", "Distro with highest complexity", "Distro with lowest complexity"]
summarized_complexity_changes = sorted(summarized_complexity_changes, key=lambda x: x[0])

Expand Down

0 comments on commit cf3a807

Please sign in to comment.