openpetswithchatandmcp/website/analyze-ast-sizes2.ts
OpenPets Dev 65ac83849e Add 'website/' from commit '966aea480ffe1c340553aa878def30131d2af827'
git-subtree-dir: website
git-subtree-mainline: 8d3849caea
git-subtree-split: 966aea480f
2026-06-17 20:48:39 +00:00

20 lines
942 B
TypeScript
Executable file

import { Project, SyntaxKind } from 'ts-morph';
const project = new Project({ tsConfigFilePath: 'C:/ScriptoriumAI/scriptoriumai-ui/tsconfig.json' });
const sf = project.getSourceFileOrThrow('C:/ScriptoriumAI/scriptoriumai-ui/src/__tests__/Runboard.telemetry-lockstep-parity.test.tsx');
const tests = sf.getDescendantsOfKind(SyntaxKind.CallExpression).filter(c => c.getExpression().getText() === 'it');
tests.sort((a,b) => b.getWidth() - a.getWidth());
const biggestTest = tests[0];
const stmts = biggestTest.getArguments()[1].asKindOrThrow(SyntaxKind.ArrowFunction).getBody().asKindOrThrow(SyntaxKind.Block).getStatements();
let sorted = [...stmts].sort((a,b) => b.getWidth() - a.getWidth());
for(let i=0; i<10; i++) {
const s = sorted[i];
if(s) {
console.log('Stmt ' + i + ' size: ~' + Math.round(s.getWidth()/1024) + 'KB (' + s.getKindName() + ')');
console.log(s.getText().substring(0, 100) + '...');
}
}