fork of hey-api/openapi-ts because I need some additional things
1import fs from 'node:fs';
2import path from 'node:path';
3import { fileURLToPath } from 'node:url';
4
5const __filename = fileURLToPath(import.meta.url);
6const __dirname = path.dirname(__filename);
7
8// Load your exported graph
9const nodes = JSON.parse(
10 fs.readFileSync(path.resolve(__dirname, 'graph.json'), 'utf-8'),
11);
12
13// Annotate nodes with children count
14const annotatedNodes = nodes.map((n) => ({
15 childrenCount: n.childrenPointers?.length ?? 0,
16 pointer: n.pointer,
17}));
18
19// Sort by childrenCount descending
20annotatedNodes.sort((a, b) => b.childrenCount - a.childrenCount);
21
22// Print top 20 hotspots
23console.log('Top 20 potential bottleneck nodes:\n');
24annotatedNodes.slice(0, 20).forEach((n) => {
25 console.log(`${n.pointer} — children: ${n.childrenCount}`);
26});