gpui: Fix flaky foreground hang detection test (#64996)

`profiler::hang::tests::detects_randomly_placed_foreground_hangs` fails
intermittently on busy CI runners
([example](https://github.com/zed-industries/zed/actions/runs/36730430144)):

```
expected every observed Render hang to correspond to one injection; expected [19ms], observed [14.99977ms, 19.776718ms]
```

The test injects 1–4 sleeping renders, inputs, actions, or task polls,
then counted every reported event of each kind lasting at least
`HANG_THRESHOLD` (10ms) and required that count to equal the number
injected. On a loaded machine an ordinary, uninjected `draw_window` can
exceed 10ms and is correctly reported as a hang, which broke the count.

The test now records the real-time window around each injection and
requires exactly one reported contributor of the injected kind inside
that window, at least as long as the injected sleep. Contributors
outside every injection window are ignored. It still fails if an
injected hang is missed, reported twice, attributed to the wrong kind,
or reported shorter than the sleep. Test-only change.

Verification (macOS):
- `ITERATIONS=200` passes.
- Removing the render sleep makes it fail with `expected injected Render
hang of 20ms to be reported exactly once; observed []`.
- I couldn't reproduce the original flake locally, even with the CPU
saturated (0/60 failures for both the old and new test), so the CI
failure itself hasn't been reproduced.
- `./script/clippy -p gpui` is clean.

Release Notes:

- [GPUI] Fixed a flaky foreground hang detection test
d284cbbc87Anthony Eid committed on 9/30/2026, 4:30:43 PM· committed by GitHubparent8da42dd
1 file changedLine totals unavailable