Skip to content

Add benchmarks and optimize hot paths#3995

Draft
nstepien wants to merge 1 commit intomainfrom
perf/benchmarks-and-optimizations
Draft

Add benchmarks and optimize hot paths#3995
nstepien wants to merge 1 commit intomainfrom
perf/benchmarks-and-optimizations

Conversation

@nstepien
Copy link
Collaborator

@nstepien nstepien commented Mar 8, 2026

Summary

  • Add vitest bench infrastructure with browser-based render benchmarks, hook-level benchmarks (useViewportRows, useCalculatedColumns), and utility micro-benchmarks
  • Memoize HeaderCell with React.memo, pre-compute sort info via useMemo Map in HeaderRow, and stabilize callback identity with useLatestFunc — eliminating per-cell O(n) findIndex scans and unnecessary re-renders
  • Lazy-copy templateColumns array in useColumnWidths (only spread when modifications are needed)
  • Replace columnMetrics Map with plain array in useCalculatedColumns for faster index-based access in viewport calculation

Test plan

  • All 317 functional tests pass
  • TypeScript compiles cleanly
  • ESLint passes
  • Benchmarks run successfully via npm run bench

🤖 Generated with Claude Code

- Add vitest bench infrastructure: render, hook, and utility benchmarks
- Memoize HeaderCell with React.memo to prevent unnecessary re-renders
- Pre-compute sort info via Map in HeaderRow instead of per-cell findIndex
- Stabilize sort callback identity with useLatestFunc
- Lazy-copy templateColumns array in useColumnWidths (only spread when needed)
- Replace columnMetrics Map with plain array for faster index-based access

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.52%. Comparing base (e533510) to head (7e0f9b5).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3995      +/-   ##
==========================================
+ Coverage   97.51%   97.52%   +0.01%     
==========================================
  Files          36       36              
  Lines        1449     1456       +7     
  Branches      463      468       +5     
==========================================
+ Hits         1413     1420       +7     
  Misses         36       36              
Files with missing lines Coverage Δ
src/HeaderCell.tsx 94.44% <100.00%> (-1.34%) ⬇️
src/HeaderRow.tsx 100.00% <100.00%> (ø)
src/hooks/useCalculatedColumns.ts 100.00% <100.00%> (ø)
src/hooks/useColumnWidths.ts 98.63% <100.00%> (+0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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