23 lines
927 B
TypeScript
Executable file
23 lines
927 B
TypeScript
Executable file
|
|
import { Project, SyntaxKind, 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 totalSize = 0;
|
|
let names = [];
|
|
const vars = sourceFile.getDescendantsOfKind(SyntaxKind.VariableDeclaration);
|
|
|
|
for (const v of vars) {
|
|
const init = v.getInitializer();
|
|
if (init && (Node.isObjectLiteralExpression(init) || Node.isArrayLiteralExpression(init))) {
|
|
const size = init.getWidth();
|
|
if (size > 50000) { // >50KB
|
|
const n = v.getName();
|
|
console.log('Found massive var: ' + n + ' ~' + Math.round(size/1024) + 'KB');
|
|
totalSize += size;
|
|
names.push(n);
|
|
}
|
|
}
|
|
}
|
|
console.log('Total extracted size: ' + Math.round(totalSize/1024) + 'KB');
|
|
|