Artifact 5c65bd75c85a2cbe43837e4d8b4a6808e3e15f63e3407b604b6ff2cd41a7072d:
- File
internal/timing/storebusy_test.go
— part of check-in
[17454ef71f]
at
2026-08-31 15:37:28
on branch trunk
— the footer names store wait the timing context missed
A call on context.Background() carries no timer, so a page blocking six seconds on a warm pass reported 'ops 11.09s, zit 32.9ms' — and the ops panel's claim that ops minus zit is index work was false while it did. Overlap catches what attribution misses: subprocess busy time inside the render window, unioned, reported only when it exceeds what was already attributed. (user: quarry, size: 1571) [annotate] [blame] [check-ins using]
package timing import ( "testing" "time" ) // The footer reported "ops 11.09s×8, zit 32.9ms" on a page whose real // cost was six seconds of a zit call made on context.Background(). The // timer lives in the request context, so a detached call is invisible // to it while the render still waits. The store note is what makes that // wait visible. func TestStoreBusyNamesWaitTheContextMissed(t *testing.T) { got := WithStoreBusy("ops 11.09s×8, zit 32.9ms", 6*time.Second) if got == "ops 11.09s×8, zit 32.9ms" { t.Fatal("six seconds of store wait went unreported") } if want := "store "; !contains(got, want) { t.Errorf("breakdown %q does not name the store wait", got) } } // When the render's own zit total already covers the busy window there // is nothing new to say, and a second number would only invite adding // the two together. func TestStoreBusyStaysQuietWhenAlreadyAttributed(t *testing.T) { in := "ops 500ms×3, zit 400ms" if got := WithStoreBusy(in, 300*time.Millisecond); got != in { t.Errorf("added a redundant note: %q", got) } if got := WithStoreBusy(in, 0); got != in { t.Errorf("added a note for no busy time: %q", got) } } // A page with no other timing still reports the wait rather than // dropping it. func TestStoreBusyOnAnEmptyBreakdown(t *testing.T) { if got := WithStoreBusy("", 2*time.Second); got == "" { t.Error("store wait dropped when there was nothing else to say") } } func contains(h, n string) bool { for i := 0; i+len(n) <= len(h); i++ { if h[i:i+len(n)] == n { return true } } return false }