feat(cli): show parse times in testing output#3939
Merged
amaanq merged 4 commits intotree-sitter:masterfrom Dec 23, 2024
WillLillis:test_timers
Merged
feat(cli): show parse times in testing output#3939amaanq merged 4 commits intotree-sitter:masterfrom WillLillis:test_timers
amaanq merged 4 commits intotree-sitter:masterfrom
WillLillis:test_timers
Conversation
amaanq
reviewed
Nov 24, 2024
This comment was marked as resolved.
This comment was marked as resolved.
touchup warning in case NOCOLOR is used fix: prevent divide by 0
Member
Author
|
(In case anyone is curious) Performance comparison against master for the original approach in this PR: After 251d7ed (only runs the test corpus once): |
amaanq
approved these changes
Dec 23, 2024
Member
amaanq
left a comment
There was a problem hiding this comment.
awesome work on the perf improvement, looks much better!
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


This adds timing information in two forms for the cli's
testsubcommand. By default, the CLI will now print out some timing stats at the end of a run. For example, runningtree-sitter testontree-sitter-cnow looks like:ambiguities: 1. ✓ pointer declarations vs expressions 2. ✓ casts vs multiplications 3. ✓ function-like type macros vs function calls ... 83. ✓ Attributes types: 84. ✓ Primitive types 85. ✓ Type modifiers Total parses: 85; successful parses: 85; failed parses: 0; success percentage: 100.00%; average speed: 2058 bytes/ms syntax highlighting: ✓ keywords.c (3 assertions) ✓ names.c (20 assertions)In addition, runningThe use case outlined in #3929 describes finding tests with slow parse rates. Simply printing the parse times isn't useful in this regard (tests vary a lot from run to run even on the same hardware). Providing the parse rate is more useful, but still leaves the user with a lot of guess work and manual checking. A solution I arrived at is to check for statistically significant slow parse rates. The process is basically as follows:tree-sitter test --show-timeswill display the parsing time for each individual test case.tree-sitter testis run, parse all relevant test cases and record their adjusted (logarithmic) parse rates.By default the
--stat outliers-and-totaloption is passed, meaning that runningtree-sitter testwill display a warning if any tests have a slow parse rate. If--stat allis passed, the parse rates for every test will be displayed as well as any outliers. Finally, passing--stat total-onlywill only display the total parsing statistics at the end.This could look like the following for tree-sitter-c, which has one test that occasionally triggers this check:
And here's a screenshot of the
--stat allflag being passed for good measure:Closes #3929