Files
tamagotchi-paradise-ko/t7/test/proft7.py
T
syskiller 2d48091205 줄바꿈을 LF로 통일
서버에서 바로 빌드하고 고칠 수 있게 저장소 줄바꿈을 LF로 맞췄습니다.
CRLF로 들어가 있던 sh 빌드 스크립트도 이제 리눅스에서 그대로 돌아갑니다.
내용은 바뀌지 않았습니다.
2026-11-24 07:13:54 +09:00

17 lines
954 B
Python

# per-function instruction profile of t7.bin in Unicorn (uses devt7 setup)
import sys, os, struct, subprocess, collections
os.environ.setdefault('SHOTS','')
src = open(os.path.join(os.path.dirname(__file__), 'devt7.py')).read()
src = src.replace("while state['ms'] < total_ms", "cnt=collections.Counter()\nFROM=int(os.environ.get('FROM','0'))\ndef hc(uc,a,s,d):\n if state['ms']>=FROM: cnt[a]+=1\nu.hook_add(UC_HOOK_CODE,hc,begin=0,end=0xffff)\nwhile state['ms'] < total_ms")
exec(compile(src, 'devt7', 'exec'))
fn = sorted((v, k) for k, v in syms.items() if v < 0x10000)
import bisect
keys=[a for a,_ in fn]
per=collections.Counter()
for a,c in cnt.items():
i=bisect.bisect_right(keys,a)-1; per[fn[i][1] if i>=0 else '?']+=c
tot=sum(per.values())
for n,c in per.most_common(25): print('%-28s %6.2f%%' % (n, 100*c/tot))
e=syms.get('t7_cpu_step',0)&~1
print('6502 instructions', cnt[e], 'ARM instr total', tot, 'per 6502 instr', tot/max(1,cnt[e]))