Repository navigation
Commit 335331e
committed
perf(ccusage): cache usage date formatting
Cache formatted usage dates per UTC hour while loading reports. The hot path previously created a Date and formatted through Intl for every usage line; daily, session, and block loading now reuse a per-command formatter/cache so repeated entries in the same hour do not pay that cost again.
Reliable runtime benchmark data is not included in this commit because process checks still showed cmux at roughly 150% CPU and Arc at roughly 60% CPU. The built bundle is 516.30 kB total after this change.
Verified with pnpm run format, pnpm typecheck, pnpm --filter ccusage exec vitest run src/data-loader.ts src/_date-utils.ts src/debug.ts, pnpm --filter ccusage run build, pnpm run test, JS/Rust token-total parity checks for daily/session/monthly/weekly/blocks, and timezone parity checks for UTC, Asia/Tokyo, America/New_York, and Europe/London.1 parent 641f7a1 commit 335331e
2 files changed
Lines changed: 22 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
52 | 67 | | |
53 | 68 | | |
54 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
1223 | 1224 | | |
1224 | 1225 | | |
1225 | 1226 | | |
| 1227 | + | |
1226 | 1228 | | |
1227 | 1229 | | |
1228 | 1230 | | |
| |||
1254 | 1256 | | |
1255 | 1257 | | |
1256 | 1258 | | |
1257 | | - | |
| 1259 | + | |
1258 | 1260 | | |
1259 | 1261 | | |
1260 | 1262 | | |
| |||
1413 | 1415 | | |
1414 | 1416 | | |
1415 | 1417 | | |
| 1418 | + | |
1416 | 1419 | | |
1417 | 1420 | | |
1418 | 1421 | | |
| |||
1563 | 1566 | | |
1564 | 1567 | | |
1565 | 1568 | | |
1566 | | - | |
| 1569 | + | |
1567 | 1570 | | |
1568 | 1571 | | |
1569 | 1572 | | |
| |||
1912 | 1915 | | |
1913 | 1916 | | |
1914 | 1917 | | |
| 1918 | + | |
1915 | 1919 | | |
1916 | 1920 | | |
1917 | 1921 | | |
| |||
2045 | 2049 | | |
2046 | 2050 | | |
2047 | 2051 | | |
2048 | | - | |
2049 | | - | |
2050 | | - | |
2051 | | - | |
| 2052 | + | |
2052 | 2053 | | |
2053 | 2054 | | |
2054 | 2055 | | |
| |||
0 commit comments