2020-09-27 20:13:50 +02:00
|
|
|
#! /usr/bin/python3
|
|
|
|
|
2021-11-12 13:23:43 +01:00
|
|
|
import json
|
2020-09-27 03:02:29 +02:00
|
|
|
import glob
|
|
|
|
import os
|
2021-06-21 06:30:57 +02:00
|
|
|
|
2021-11-19 15:31:28 +01:00
|
|
|
print_funcs = True
|
2020-09-27 03:02:29 +02:00
|
|
|
|
|
|
|
sizes = {}
|
|
|
|
|
2021-06-21 06:30:57 +02:00
|
|
|
funcs = {}
|
|
|
|
|
2020-09-27 03:02:29 +02:00
|
|
|
def calc_insns(f_path):
|
|
|
|
ret = 0
|
|
|
|
with open(f_path) as f:
|
|
|
|
f_lines = f.readlines()
|
|
|
|
for line in f_lines:
|
|
|
|
if line.startswith("/* "):
|
|
|
|
ret += 1
|
2021-06-21 06:30:57 +02:00
|
|
|
funcs[f_path.split("/")[-1][:-2]] = ret
|
2020-09-27 03:02:29 +02:00
|
|
|
return ret
|
|
|
|
|
|
|
|
def do_dir(root, dir):
|
|
|
|
max = 0
|
|
|
|
min = None
|
|
|
|
total = 0
|
|
|
|
|
|
|
|
files = glob.glob(os.path.join(root, dir) + "/*.s")
|
|
|
|
|
|
|
|
for f in files:
|
|
|
|
amt = calc_insns(f)
|
|
|
|
if amt > max:
|
|
|
|
max = amt
|
|
|
|
if min is None or amt < min:
|
|
|
|
min = amt
|
|
|
|
total += amt
|
2020-11-23 19:48:34 +01:00
|
|
|
|
2020-09-27 03:02:29 +02:00
|
|
|
avg = 0 if len(files) == 0 else total / len(files)
|
|
|
|
|
2021-06-30 04:27:12 +02:00
|
|
|
sizes[dir] = ((min, max, total, avg, len(files)))
|
2020-09-27 03:02:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
script_dir = os.path.dirname(os.path.realpath(__file__))
|
2021-02-22 10:21:23 +01:00
|
|
|
asm_dir = script_dir + "/../ver/current/asm/nonmatchings"
|
2020-09-27 03:02:29 +02:00
|
|
|
|
|
|
|
for root, dirs, files in os.walk(asm_dir):
|
|
|
|
for asm_dir in dirs:
|
2021-07-22 20:48:30 +02:00
|
|
|
if "/os" not in root and "/world/" not in root:
|
2020-09-27 03:02:29 +02:00
|
|
|
do_dir(root, asm_dir)
|
|
|
|
|
2021-06-30 04:27:12 +02:00
|
|
|
for thing in sorted(sizes.keys(), key=lambda x: sizes[x][4]):
|
|
|
|
val = sizes[thing][4]
|
2021-01-03 10:34:04 +01:00
|
|
|
if val > 0:
|
|
|
|
print(thing.ljust(25) + str(val))
|
2021-06-21 06:30:57 +02:00
|
|
|
|
|
|
|
if print_funcs:
|
2021-11-12 13:23:43 +01:00
|
|
|
print(json.dumps(dict(sorted(funcs.items(), key=lambda f: f[1])), indent=4))
|