Skip to content

Emit timing information for rule applications#799

Merged
jackfirth merged 2 commits into
masterfrom
rule-application-timing
Jul 8, 2026
Merged

Emit timing information for rule applications#799
jackfirth merged 2 commits into
masterfrom
rule-application-timing

Conversation

@jackfirth

Copy link
Copy Markdown
Owner

Fixes #798.

Resyntax now records how much time it spends testing each refactoring rule on each syntax object to see if it produces a suggestion. Once per analyzed source, it logs a table mapping rule names to the total time spent checking that rule, summed across each individual application. The table is logged with the resyntax debug logger.

Implementation:

  • refactoring-rules-refactor takes a #:rule-timings mutable hash and wraps each rule application in a refactor/timed helper that measures elapsed time with current-inexact-monotonic-milliseconds and accumulates it per rule name.
  • refactor-visited-forms creates the hash, threads it through all visited forms of a source, then logs the table via a new log-rule-timings helper. The helper guards on (log-level? resyntax-logger 'debug) so the pretty-printed table is only built when a receiver is listening at debug level.
  • Rules that were never reached (because an earlier rule matched first on every form) don't appear in the table.

Example output from PLTSTDERR="debug@resyntax error" resyntax analyze --file demo.rkt:

resyntax: total time spent checking each rule against demo.rkt (in milliseconds):
  '#hash((add-between-wrong-argument-order . 0.161)
         (add1-lambda-to-add1 . 0.089)
         (always-throwing-cond-to-when . 0.180)
         ...)

Testing: added a test that attaches a debug-level log receiver, runs resyntax-analyze, and checks that exactly one timing message is emitted for the analyzed source. raco test main.rkt test/ passes.

🤖 Generated with Claude Code

Resyntax now records how much time it spends testing each refactoring
rule on each syntax object. Once per analyzed source, it logs a table
mapping rule names to the total time spent checking that rule, summed
across each individual application. The table is logged with the
resyntax debug logger.

Fixes #798.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Resyntax analyzed 1 file in this pull request and found no issues.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 93.98% (+0.007%) from 93.973% — rule-application-timing into master

The timing measurements are only used by the debug log message, so
skip the clock reads and hash updates entirely when no log receiver
is listening at debug level.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jackfirth jackfirth marked this pull request as ready for review July 8, 2026 09:14
@jackfirth jackfirth enabled auto-merge (squash) July 8, 2026 09:14

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Resyntax analyzed 1 file in this pull request and found no issues.

@jackfirth jackfirth merged commit aa26551 into master Jul 8, 2026
8 checks passed
@jackfirth jackfirth deleted the rule-application-timing branch July 8, 2026 09:18

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Resyntax analyzed 1 file in this pull request and found no issues.

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.

Emit timing information for rule applications

2 participants