1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-25 09:45:02 +00:00
oot/tools/compare_actors_sizes.py
Anghelo Carvajal d1a9775926
Improve the get_actor_sizes.py script (#673)
* the script now should be able to parse the files in the build folder

also added some flags to ignore an actor list and parse the non-matching like before

Signed-off-by: angie <angheloalf95@gmail.com>

* bit of cleanup

Signed-off-by: angie <angheloalf95@gmail.com>

* script to compare the results

Signed-off-by: angie <angheloalf95@gmail.com>

* dont assume every function is in just one file

Signed-off-by: angie <angheloalf95@gmail.com>

* fix qword allign

Signed-off-by: angie <angheloalf95@gmail.com>

* move the csv stuff to a function

Signed-off-by: angie <angheloalf95@gmail.com>

* add flag to export the amount of instructions per function

add examples for how to use the script
fix a bug

Signed-off-by: angie <angheloalf95@gmail.com>

* add include-only flag

Signed-off-by: angie <angheloalf95@gmail.com>

* delete extra file

Signed-off-by: angie <angheloalf95@gmail.com>

* keep functions order

Signed-off-by: angie <angheloalf95@gmail.com>
2021-02-02 13:30:34 -05:00

38 lines
937 B
Python

#!/usr/bin/python3
import argparse
def read_csv(csv_file):
f_lines = ""
with open(csv_file) as f:
f_lines = f.readlines()[1:]
overlays = {}
for line in f_lines:
row = line.split(",")
overlays[row[0]] = int(row[3])
return overlays
def main():
parser = argparse.ArgumentParser(description="Compares two csv produced by `get_actor_sizes.py`.")
parser.add_argument("firstcsv", help="")
parser.add_argument("secondcsv", help="")
args = parser.parse_args()
first = read_csv(args.firstcsv)
second = read_csv(args.secondcsv)
print(f"overlay,{args.firstcsv},{args.secondcsv},diff")
common_actors = set(first.keys()) & set(second.keys())
for actor_name in common_actors:
total_1 = first[actor_name]
total_2 = second[actor_name]
if total_1 != total_2:
print(f"{actor_name},{total_1},{total_2},{total_1-total_2}")
main()