Skip to content

WIP: calculate line/chunk hotness#99

Draft
bartveneman wants to merge 1 commit intomainfrom
feat/hotness
Draft

WIP: calculate line/chunk hotness#99
bartveneman wants to merge 1 commit intomainfrom
feat/hotness

Conversation

@bartveneman
Copy link
Member

New output fields:

  • chunk.coverage_count: number — how many input Coverage objects covered that chunk (0 = uncovered, 1+ = covered N times)
    = chunk.is_covered: boolean — unchanged, backward-compatible (= coverage_count > 0)
    = result.max_coverage_count: number — highest count across all chunks in a stylesheet/result

Files changed:

  • decuplicate.ts — new WeightedRange/WeightedCoverage types + sweep-line algorithm that counts overlapping ranges, then merges adjacent same-count segments (preserving the old 1-byte tolerance)
  • extend-ranges.ts — made generic so it works with both plain and weighted ranges
  • chunkify.ts — coverage_count added to Chunk; adjacent covered chunks merge keeping the max count (needed to keep line counts stable when the same stylesheet is loaded multiple times)
  • index.ts — threads WeightedCoverage through the pipeline; computes max_coverage_count in stats

Design note: Adjacent covered chunks with different counts are merged keeping the max count. This is intentional — it preserves correct line counts when the same stylesheet is covered in overlapping but not identical ways across multiple sessions.


some issues still preventing me from merging this:

  1. When a large chunk that was covered once contains a chunk that was covered 10 times, the whole large chunk gets marked with 10 hits. Meh.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 98.52941% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.74%. Comparing base (1415c5b) to head (5c7e9a4).

Files with missing lines Patch % Lines
src/lib/decuplicate.ts 97.22% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #99      +/-   ##
==========================================
+ Coverage   96.71%   96.74%   +0.03%     
==========================================
  Files          14       14              
  Lines        1064     1107      +43     
  Branches      142      150       +8     
==========================================
+ Hits         1029     1071      +42     
- Misses         34       35       +1     
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codecov-commenter
Copy link

Bundle Report

Changes will increase total bundle size by 1.35kB (5.02%) ⬆️⚠️, exceeding the configured threshold of 5%.

Bundle name Size Change
index.js-esm 14.39kB 1.35kB (10.33%) ⬆️⚠️

Affected Assets, Files, and Routes:

view changes for bundle: index.js-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
index.js 1.1kB 12.78kB 9.43% ⚠️
index.d.ts 246 bytes 1.6kB 18.1% ⚠️

Files in index.js:

  • ./src/lib/extend-ranges.ts → Total Size: 1.02kB

  • ./src/lib/chunkify.ts → Total Size: 2.77kB

  • ./src/lib/index.ts → Total Size: 2.75kB

  • ./src/lib/decuplicate.ts → Total Size: 1.41kB

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