23 lines
968 B
TypeScript
Executable file
23 lines
968 B
TypeScript
Executable file
|
|
import { Project, Node } from 'ts-morph';
|
|
const project = new Project({ tsConfigFilePath: 'C:/ScriptoriumAI/scriptoriumai-ui/tsconfig.json' });
|
|
const sourceFile = project.getSourceFileOrThrow('C:/ScriptoriumAI/scriptoriumai-ui/src/__tests__/Runboard.telemetry-lockstep-parity.test.tsx');
|
|
|
|
let totalLiteralSize = 0;
|
|
let literalCount = 0;
|
|
const vars = sourceFile.getVariableDeclarations();
|
|
console.log('Vars count: ' + vars.length);
|
|
|
|
for (const v of vars) {
|
|
const init = v.getInitializer();
|
|
if (init && (Node.isObjectLiteralExpression(init) || Node.isArrayLiteralExpression(init))) {
|
|
const size = init.getWidth();
|
|
if (size > 10000) {
|
|
console.log('Var ' + v.getName() + ' size: ~' + Math.round(size/1024) + 'KB');
|
|
totalLiteralSize += size;
|
|
literalCount++;
|
|
}
|
|
}
|
|
}
|
|
console.log('Total extracted size possible: ~' + Math.round(totalLiteralSize/1024) + 'KB across ' + literalCount + ' declarations.');
|
|
|