Skip to content

Commit

Permalink
Report function alignment accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
disinvite committed Jan 4, 2025
1 parent 99dc586 commit 6c7ca8f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions reccmp/tools/asmcmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ def main():

### Compare everything.

# Count how many functions have the same virtual address in orig and recomp.
functions_aligned_count = 0

# Number of functions compared (i.e. excluding stubs)
function_count = 0
total_accuracy = 0
total_effective_accuracy = 0
Expand All @@ -275,6 +279,12 @@ def main():
match, show_both_addrs=args.print_rec_addr, is_plain=args.no_color
)

if (
match.match_type == SymbolType.FUNCTION
and match.orig_addr == match.recomp_addr
):
functions_aligned_count += 1

if match.match_type == SymbolType.FUNCTION and not match.is_stub:
function_count += 1
total_accuracy += match.ratio
Expand Down Expand Up @@ -322,15 +332,20 @@ def main():

implemented_funcs = function_count

# Substitute an alternate value for the total number of functions in the file
if args.total:
function_count = int(args.total)

if function_count > 0:
effective_accuracy = total_effective_accuracy / function_count * 100
actual_accuracy = total_accuracy / function_count * 100
alignment_accuracy = functions_aligned_count / function_count * 100
print(
f"\nTotal effective accuracy {effective_accuracy:.2f}% across {function_count} functions ({actual_accuracy:.2f}% actual accuracy)"
)
print(
f"{functions_aligned_count} functions are aligned ({alignment_accuracy:.2f}%)"
)

if args.svg is not None:
gen_svg(
Expand Down

0 comments on commit 6c7ca8f

Please sign in to comment.