File size: 3,851 Bytes
2dc44f1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | #!/usr/bin/env python3
"""73_telemetria_v090.py — telemetria do projeto v0.9.0 (Aprimoramento 4 e
custos das críticas Qwen3.8): estrutura (God Object dissolvido), tempos de
compilação medidos (frios, target dirs separados), contagens de testes e
inventário de módulos. Saída: resultados/telemetria_v090.json
"""
import json, os, re, subprocess
def main():
pasta = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
rel = {"versao": "0.9.0"}
# ---- estrutura: God Object dissolvido
lib = os.path.join(pasta, "src", "lib.rs")
py = os.path.join(pasta, "src", "python.rs")
lib_sz = os.path.getsize(lib)
py_sz = os.path.getsize(py)
lib_txt = open(lib, encoding="utf-8").read()
py_txt = open(py, encoding="utf-8").read()
mods = len(re.findall(r"^pub mod (\w+);", lib_txt, re.M))
pyfuncs = len(re.findall(r"#\[pyfunction\]", py_txt))
pyclasses = len(re.findall(r"#\[pyclass\]", py_txt))
# dependências mortas removidas (grep: zero usos no fonte)
removidas = ["numpy 0.23 (0 usos)", "dict_derive 0.5 (0 usos)",
"pyo3-built 0.5 (0 usos)"]
rel["estrutura"] = {
"lib_rs_bytes": lib_sz, "lib_rs_bytes_v080": 104558,
"python_rs_bytes": py_sz,
"razao_de_tamanho": round(104558 / lib_sz, 1),
"modulos_dominio": mods, "pyfunctions": pyfuncs, "pyclasses": pyclasses,
"deps_mortas_removidas": removidas,
"dominio_importa_pyo3": False, # verificado: só python.rs e treino.rs ANTES; agora só python.rs
"arquivos_fonte": len([f for f in os.listdir(os.path.join(pasta, "src")) if f.endswith(".rs")]),
}
# ---- compilação (medições da sessão; builds frios, dirs separados)
# proveniência: logs/compila_dominio.log e logs/compila_full.log
rel["compilacao"] = {
"dominio_compila": True,
"tempo_frio_dominio_s": 70, # cargo test --no-default-features --no-run (alvo limpo)
"tempo_frio_completo_s": 85, # cargo test --no-run (python+ponte_async; alvo limpo)
"overhead_python_pct": round(100 * (85 - 70) / 85, 1),
"nota": "alegação Qwen '≈40%' CORRIGIDA por medição: overhead real "
"desta máquina ~18% (70s vs 85s, builds frios com candle igual)",
}
# ---- testes (suítes executadas na sessão; determinismo 3×)
rel["testes"] = {
"cargo_dominio_sem_python": "105+2 = 107/107",
"cargo_completo": "105+2 = 107/107",
"determinismo": "3 execuções idênticas",
"herdados_v080": 99, "novos_v090": 8,
"novos": ["f13_skew_bit_a_bit", "f14_skew_gradiente_e_escala",
"sq1_calibrar_bit_a_bit", "sq2_calibrar_smoke",
"tv1a_construtor_recusa", "tv1b_construtor_aceita",
"tv1c_complemento", "tv2_gate_tipado_dominio"],
}
# ---- inventário de módulos (bytes)
rel["modulos"] = {
f: os.path.getsize(os.path.join(pasta, "src", f))
for f in sorted(os.listdir(os.path.join(pasta, "src")))
if f.endswith(".rs")
}
# ---- deprecados e oráculos (superfície pública v0.9.0)
rel["api"] = {
"deprecados": ["MoeRedirecionavel::fwd (pub(crate), bug v080-1 — oráculo de testes)"],
"renomeados": {"fwd_vetorizado": "forward"},
"opt_in": ["SuavizadorQuant::calibrar_tensor (backends acelerados)"],
"removidos_da_api_publica": [],
}
with open(os.path.join(pasta, "resultados", "telemetria_v090.json"), "w") as f:
json.dump(rel, f, indent=1, ensure_ascii=False)
print(f"lib.rs {lib_sz} B (era 104558) | python.rs {py_sz} B | "
f"{mods} módulos | {pyfuncs} pyfunctions | overhead python "
f"{rel['compilacao']['overhead_python_pct']}%")
print("OK: resultados/telemetria_v090.json")
if __name__ == "__main__":
main()
|