Published on

Visualizing Code Stats

Authors
  • avatar
    Name
    Teddy Xinyuan Chen
    Twitter

I made some tools that uses AST to get the source for symbols, tokei, and plotly to visualize the code stats.

Example: https://github.com/tddschn/questdb-rest#code-stats

They're not made for a small codebase like questdb-rest, but for my personal projects for 40k+ lines of Python and growing.

As my codebase grows, it gets harder to get a sense of where the long chunks of code is located (because there are so many 800 line long functions).

QuestDB-Rest v3.0.3

LOC by file

With tokei.

Full screen: https://g.teddysc.me/511ceb311b59770268a709a589ce4fef

Token count by function

With AST & tiktoken.

Full screen: https://g.teddysc.me/5c5532cb807d1af05e8f94a100d5d758

This shows how complex the create-or-replace-table-from-query subcommand is.

Function LOC Sunburst Chart

With AST.

Full screen: https://g.teddysc.me/4b237bf675c319dabe99cf7edb6f79e2

You can click on the middle layer to expand, like this:

alt text
Expanded for __init__py