Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: print AST statistics with -Zast-stats flag #125

Merged
merged 9 commits into from
Nov 19, 2024

Conversation

Chriscbr
Copy link
Contributor

Closes #25

For example, running cargo run -- -Z ast-stats examples/src/Counter.sol from the project root emits:

ast-stats AST STATS
ast-stats Name                Accumulated Size         Count     Item Size
ast-stats ----------------------------------------------------------------
ast-stats Block                     32 ( 2.7%)             2            16
ast-stats Type                      64 ( 5.4%)             2            32
ast-stats - Elementary                64 ( 5.4%)             2
ast-stats Stmt                     160 (13.6%)             2            80
ast-stats - Expr                     160 (13.6%)             2
ast-stats Expr                     240 (20.4%)             5            48
ast-stats - Assign                    48 ( 4.1%)             1
ast-stats - Unary                     48 ( 4.1%)             1
ast-stats - Ident                    144 (12.2%)             3
ast-stats Item                     680 (57.8%)             5           136
ast-stats - Variable                 136 (11.6%)             1
ast-stats - Contract                 136 (11.6%)             1
ast-stats - Pragma                   136 (11.6%)             1
ast-stats - Function                 272 (23.1%)             2
ast-stats ----------------------------------------------------------------
ast-stats Total                  1_176
ast-stats

Copy link
Contributor Author

@Chriscbr Chriscbr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a first pass at adding a form of AST stats. The approach is heavily based on that of rustc; looking for any feedback!

crates/sema/src/lib.rs Show resolved Hide resolved
crates/sema/src/stats.rs Show resolved Hide resolved
crates/sema/src/stats.rs Outdated Show resolved Hide resolved
crates/sema/src/stats.rs Show resolved Hide resolved
@Chriscbr Chriscbr requested a review from DaniPopes November 17, 2024 02:31
crates/sema/src/stats.rs Outdated Show resolved Hide resolved
@Chriscbr Chriscbr requested a review from DaniPopes November 19, 2024 04:23
Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@DaniPopes DaniPopes merged commit 53e1f85 into paradigmxyz:main Nov 19, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Print AST statistics
2 participants