3 Commits

Author SHA1 Message Date
yoshiko 933875d1a8 fix(ci): stabilize keyboard benchmark (#256)
Use a deterministic shared diff, discard warm-up iterations, and balance run order across two rounds before comparing merged results.
2026-03-18 23:20:41 +09:00
Noritaka Kobayashi 1a105de150 refactor: Remove unused imports and variables in generate-large-diff.js (#77) 2025-08-02 17:23:18 +09:00
haya14busa 607f6d9a81 perf: Improve keyboard navigation performance with React.memo (#72)
* Add script to generate large diffs for performance testing

This script generates synthetic diff files of various sizes (small, medium,
large, xlarge) to help test and improve keyboard navigation performance.

🤖 Generated with [Claude Code](https://claude.ai/code)

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

* Add performance measurement script focused on keyboard navigation

- Created measure-performance.js script for tracking navigation performance
- Added npm scripts for easy testing (perf, perf:small, perf:medium, etc.)
- Captures detailed metrics including git commit info and operation timings
- Baseline measurements show significant slowdown with larger diffs:
  - Small (500 lines): ~65ms per navigation
  - Medium (10,000 lines): ~480-500ms per navigation (7.5x slower)

🤖 Generated with [Claude Code](https://claude.ai/code)

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

* chore: Add performance-results to .gitignore

Performance test results should not be tracked in version control
as they are machine-specific and regenerated for each test run.

🤖 Generated with [Claude Code](https://claude.ai/code)

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

* refactor: Improve performance measurement script

- Fix keyboard shortcuts: use ] and [ for file navigation instead of f/F
- Fail fast when selectors are not found to avoid invalid measurements
- Reduce default iterations from 3 to 2 (configurable with --iterations)
- Remove unused measurement types to simplify the script
- Better error handling for page load failures

🤖 Generated with [Claude Code](https://claude.ai/code)

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

* chore: Remove memory measurement from performance script

Memory performance API is not available in headless Chrome by default,
so removing it to simplify the script and avoid confusion.

🤖 Generated with [Claude Code](https://claude.ai/code)

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

* feat: Add git working directory dirty state detection to performance script

Track whether there are uncommitted changes when running performance tests
to ensure reproducibility. Shows a warning when the working directory has
uncommitted changes during measurement.

🤖 Generated with [Claude Code](https://claude.ai/code)

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

* feat: Add performance comparison script

Create a script to compare two performance measurement results and display
the differences in a clear, readable format. Supports both Markdown and JSON
output formats.

Features:
- Compare average operation times and identify improvements/regressions
- Support for automatic detection of latest results by size
- Markdown table output with color-coded changes
- JSON output for programmatic processing
- Ability to save comparison results to file

Usage:
- pnpm compare:perf - Compare latest two medium results
- pnpm compare:perf small - Compare latest two small results
- pnpm compare:perf file1.json file2.json - Compare specific files
- pnpm compare:perf small --json - Output as JSON
- pnpm compare:perf small --save - Save markdown to file

🤖 Generated with [Claude Code](https://claude.ai/code)

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

* feat: Improve performance comparison script with better UX

- Change npm script from compare:perf to perf:compare for consistency
- Use --size flag instead of positional argument for better clarity
- Simplify output to focus on overall performance metrics
- Improve table formatting for better readability
- Fix argument parsing to properly handle flag values

The comparison now shows a clean summary with performance change
percentage and visual indicators for improvements/regressions.

🤖 Generated with [Claude Code](https://claude.ai/code)

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

* fix: Fix argument parsing in performance measurement script

The --headed flag was not working because it was being treated as the
size parameter. Fixed by properly filtering out flags and their values
when determining the positional size argument.

Now supports:
- pnpm perf --headed (uses default medium size)
- pnpm perf:small --headed
- pnpm perf large --headed --iterations 1

🤖 Generated with [Claude Code](https://claude.ai/code)

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

* refactor: Use --size flag for performance measurement script

Changed the performance measurement script to only accept size via
the --size flag, removing support for positional arguments. This
makes it consistent with the comparison script.

- Size must now be specified with --size flag
- Shows helpful error message when positional arguments are used
- Updated all npm scripts to use --size flag
- Added usage information when invalid size is provided

Usage:
  pnpm perf --size small --headed --iterations 1
  pnpm perf:small --headed
  pnpm perf --size medium (default)

🤖 Generated with [Claude Code](https://claude.ai/code)

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

* perf: Improve performance measurement timing accuracy

- Use setTimeout(0) before requestAnimationFrame to allow React's concurrent features to complete
- This provides more accurate measurement of actual navigation performance
- Add experimental test scripts to .gitignore

* perf: Optimize PrismSyntaxHighlighter to prevent re-renders

Add React.memo to both PrismSyntaxHighlighter and EnhancedPrismSyntaxHighlighter
components to prevent unnecessary re-renders during keyboard navigation.

Performance improvement:
- Baseline: 474.05ms average navigation time
- Optimized: 86.67ms average navigation time
- Result: 81.7% reduction in keyboard navigation latency

The optimization is particularly effective for large diffs with many syntax
highlighted code blocks, as it prevents re-rendering of unchanged code when
parent components update during navigation.

Also added useCallback for render functions to ensure proper memoization.

* feat: Add GitHub Actions workflow for performance testing

- Run performance tests on PRs comparing base vs head branches
- Show results in Job Summary and PR comments
- Fail the workflow if performance degrades by more than 10%
- Mark as improved if performance increases by more than 5%
- Handle cases where performance scripts don't exist in base branch

* feat: Add playwright as dev dependency and improve CI workflow

- Add playwright as a dev dependency in package.json
- Update GitHub Actions workflow to use the compare script properly
- Use JSON output from compare script for accurate data extraction
- Properly handle both compare and compare-fallback outputs in Job Summary

* refactor: Improve CI workflow to use head branch scripts consistently

- Setup Node.js and pnpm first before any checkouts
- Use head branch's measurement scripts to test both head and base builds
- This ensures consistent measurement methodology across versions
- Better handling of cases where base branch might have incompatible changes
- Add number formatting for cleaner display in Job Summary and PR comments

* fix: Install playwright in base branch if missing during CI

- Check if playwright is installed before running performance tests
- Install it temporarily with --no-save if missing
- This ensures tests can run even when base branch doesn't have playwright as a dependency

* fix: Use pnpm to install playwright in CI to handle workspace protocols

- Switch from npm to pnpm for installing playwright in base branch
- Fallback to npm if pnpm fails (for older versions)
- This fixes the 'Unsupported URL Type "link:"' error when base branch uses pnpm workspaces

* fix: Use pnpm exec instead of npx and remove npm fallback

- Use 'pnpm exec' instead of 'npx' for consistency
- Remove unnecessary npm fallback since we're already using pnpm
- Simplify the playwright installation logic

* ci: Remove PR comment functionality from performance workflow

Removed PR comment functionality from the GitHub Actions performance
workflow since it won't work from forks due to permission restrictions.
The workflow now only reports results to the Job Summary, which is
accessible to all users regardless of fork status.

🤖 Generated with [Claude Code](https://claude.ai/code)

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

* fix: Fix performance test result path in CI workflow

The performance test was creating results in the head directory even
when running from the base directory. Changed working-directory to
base to ensure results are created in the correct location.

🤖 Generated with [Claude Code](https://claude.ai/code)

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

* refactor: Simplify performance workflow to use compare script output directly

- Removed redundant baseline handling since head scripts always work
- Use compare script's markdown output directly for GitHub Step Summary
- Removed unnecessary file copying between directories
- Simplified JSON extraction for status checks only
- Use direct node execution instead of pnpm to avoid extra output

🤖 Generated with [Claude Code](https://claude.ai/code)

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

* fix: Remove ANSI color codes and fix variable references in compare script

- Removed ANSI color codes to prevent formatting issues in GitHub Actions
- Fixed undefined iterations error by using correct variable names (current vs compared)
- Simplified logging to use console.error for non-output messages
- Made output cleaner for CI/CD environments

🤖 Generated with [Claude Code](https://claude.ai/code)

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

* feat: Add --difit-path option to performance measurement script

Added ability to specify a custom difit binary path in the performance
measurement script. This allows the CI workflow to properly test the
base branch's build instead of always using the head branch's difit.

- Added --difit-path parameter to measure-performance.js
- Updated CI workflow to use base branch's difit build for base measurement
- Now properly compares performance between different code versions

🤖 Generated with [Claude Code](https://claude.ai/code)

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

* chore: Remove redundant playwright installation steps

Removed automatic playwright installation from both the CI workflow
and measure-performance.js since playwright is now a dev dependency
and will be installed via pnpm install.

🤖 Generated with [Claude Code](https://claude.ai/code)

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

* feat: Add Playwright browser caching to CI workflow

- Re-added playwright install step as browser binaries must be downloaded separately
- Added caching for Playwright browsers to speed up CI runs
- Cache key is based on Playwright version to ensure compatibility

Browser binaries cannot be bundled in npm packages due to their size
(~100-300MB) and platform-specific nature, so they must be installed
separately.

🤖 Generated with [Claude Code](https://claude.ai/code)

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

* feat: Add stdin support to dev.js script

Modified dev.js to support reading diffs from stdin, matching the
functionality already available in the main CLI. This allows developers
to pipe diffs directly into the dev server.

Usage examples:
- git diff | pnpm dev
- git diff | node scripts/dev.js -
- cat some.patch | pnpm dev

🤖 Generated with [Claude Code](https://claude.ai/code)

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-29 09:58:07 +09:00