Repository navigation
perf: memoise the dashboard date-label formatter (#99) - #115
Merged
Carl723000 merged 1 commit intoSep 23, 2026
Merged
Conversation
formatUsageDate called toLocaleDateString once per table row and chart point, constructing a fresh Intl.DateTimeFormat each time. That is the same per-call cost ClaudeCodeUsage#109 removed from dateKeys, and it showed up at 3-8% self time in extension-host profiles captured while the dashboard was rendering. Formatters are now cached per locale and options. When no date field is requested, the numeric year/month/day default that toLocaleDateString applies is added explicitly, so output stays identical. A new test compares the result against toLocaleDateString for all eight UI locales across several option shapes, including the cached second call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🤖 Automated first-pass review The configured analysis model did not return a usable analysis for this pull request. The item has still been received and remains available for maintainer review. To help with review, please ensure the change summary, tests, and any user-facing documentation or localization updates are included. 🤖 Posted automatically by CCU Bot — not a maintainer decision. |
Collaborator
|
Thanks @jackieyangjq for your first contribution to Claude Code Usage! The formatter cache addresses a measured dashboard hotspot, and the tests cover all eight UI locales plus the less obvious date-option cases. I appreciate the clear benchmark and careful behavior check. Merged after the Node, UI, and package checks passed. 🤖 Generated with OpenAI Codex |
7 of 11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
formatUsageDatecalledtoLocaleDateStringonce per table row and chart point,which constructs a new
Intl.DateTimeFormaton every call. This is the same cost#109 removed from
dateKeys, in the dashboard rendering path, which #109 and#111–#113 don't touch. It showed up at 3–8% self time in extension-host profiles
captured while the dashboard was rendering.
This PR caches the formatter per locale and options. When no date field is
requested, it explicitly adds the numeric year/month/day default that
toLocaleDateStringapplies, so the output is unchanged.Micro-benchmark (zh-CN, 20k labels): ~31 µs → ~1.1 µs per label.
Linked issues
Relates to #99
Type of change
fix(patch)How was this tested?
formatUsageDatewithtoLocaleDateStringfor alleight UI locales and seven option shapes (including
dateStyle,weekday,explicit zones, and a time-only option), daily and monthly, on both the first
(uncached) and second (cached) call. With the default-date-field handling
removed, the test fails, so it covers that edge case.
npm test: 1066/1067 pass. The one failure isreal Claude filesystem events flow through manifest, index, and dashboard refresh(5 s timeout in
extensionWindowActivity.test). It also fails 1 run in 5 onunmodified
main, so it looks like a pre-existing flaky test.Checklist
npm run compileis cleanCHANGELOG.mdupdatedand README items don't apply.
🤖 Generated with Claude Code