Skip to content

feat: add profile diff command#39

Merged
piotrski merged 3 commits intocallstackincubator:mainfrom
kacper-mikolajczak:feat/profile-diff
Mar 17, 2026
Merged

feat: add profile diff command#39
piotrski merged 3 commits intocallstackincubator:mainfrom
kacper-mikolajczak:feat/profile-diff

Conversation

@kacper-mikolajczak
Copy link
Copy Markdown
Contributor

Summary

  • Adds profile diff <before.json> <after.json> CLI command to compare two profiling exports
  • No daemon required - operates purely on the exported JSON files from profile export
  • Matches components by displayName, computes avg duration and render count deltas
  • Categorizes into: regressed, improved, new, removed (5% threshold filters noise)

Builds on #38 (profile export).

Usage

# Capture baseline
agent-react-devtools profile start
# ... interact ...
agent-react-devtools profile stop
agent-react-devtools profile export before.json

# Make code changes, restart app

# Capture after
agent-react-devtools profile start
# ... same interaction ...
agent-react-devtools profile stop
agent-react-devtools profile export after.json

# Compare
agent-react-devtools profile diff before.json after.json

Example output

Before: 5 commits, 234.5ms total
After:  5 commits, 189.2ms total
Delta:  -45.3ms (-19%)

Regressed (1):
  Sidebar                        avg:   2.1ms ->    4.8ms   +129%  renders: 5 -> 12

Improved (2):
  ExpensiveList                  avg:  12.3ms ->    4.1ms    -67%  renders: 47 -> 12
  TodoItem                       avg:   2.1ms ->    0.8ms    -62%  renders: 94 -> 94

New (1):
  MemoizedHeader                 avg:       - ->    0.3ms           renders: - -> 8

Test plan

  • 8 new unit tests: extractStats aggregation, regressed/improved/new/removed detection, threshold filtering, summary totals
  • All 84 tests pass
  • Manual: export two profiles, run diff, verify output

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 6, 2026

🦋 Changeset detected

Latest commit: cf0977a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
agent-react-devtools Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kacper-mikolajczak kacper-mikolajczak marked this pull request as ready for review March 6, 2026 14:40
@piotrski
Copy link
Copy Markdown
Collaborator

@kacper-mikolajczak, I've merged #38 with some fixes so the export works correctly with React DevTools (flame graphs, durations, etc.). Could you rebase this branch on the latest main? Let me know if you run into any conflicts.

Compare two exported profiling JSON files to identify regressions,
improvements, new and removed components.

- New CLI command: profile diff <before.json> <after.json> [--limit N]
- No daemon required - operates purely on exported files
- Matches components by displayName, computes avg duration deltas
- 5% threshold filters noise from insignificant changes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kacper-mikolajczak
Copy link
Copy Markdown
Contributor Author

kacper-mikolajczak commented Mar 17, 2026

@piotrski Rebased - looks like we are good to go ✅

@piotrski
Copy link
Copy Markdown
Collaborator

Hey @kacper-mikolajczak, I've merged #38 with some fixes so the export works correctly with React DevTools (flame graphs, durations, etc.). Could you rebase this branch on the latest main? Let me know if you run into any conflicts.

piotrski and others added 2 commits March 18, 2026 00:48
- Use Map lookup instead of linear scan for self durations
- Clarify before/after order in help text
- Add --threshold flag to configure regression sensitivity (default 5%)
- Show clear error messages when export files can't be read
- Show actual threshold value in "no changes" message
- Fix constant naming convention (DEFAULT_THRESHOLD_PCT)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@piotrski piotrski merged commit 65c391f into callstackincubator:main Mar 17, 2026
4 checks passed
@kacper-mikolajczak
Copy link
Copy Markdown
Contributor Author

kacper-mikolajczak commented Mar 18, 2026

Sure, I will check that in the latest version 👍

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.

2 participants