# gpui: Add async task benchmark support \(\#62180\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/300972bea37c8cc1c67804c581f62ae6ab4c040e)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 300972bea37c8cc1c67804c581f62ae6ab4c040e

Requested commit: 300972bea37c8cc1c67804c581f62ae6ab4c040e

Commit: 300972bea37c8cc1c67804c581f62ae6ab4c040e

Tree: aa25a170fbe81fb8d7ef234f2f60314359c4b25c

Author: Anthony Eid

Committer: GitHub

## Message

```
gpui: Add async task benchmark support (#62180)

### Summary

This PR improves GPUI's Criterion benchmark integration by adding
task-based measurement APIs to `BenchAppContext`. Benchmarks can now
await asynchronous GPUI operations whose completion depends on
foreground work, background work, timers, or external wakes, while
keeping setup and destruction outside the measured interval.

#### Added `BenchAppContext` APIs

- Add `bench_task` to measure a GPUI `Task` through completion in
Criterion's iteration loop.
- Add `bench_batched_task` to perform per-iteration setup outside the
timed interval before measuring a task.
- Preserve support for non-`Send` foreground task outputs and destroy
outputs after timing stops.
- Collect frame timings produced during asynchronous benchmark
iterations without including collection in the measurement.
- Drive task completion across temporary dispatcher quiescence and
externally delivered wakes.

Release Notes:

- N/A
```

## Parents

- [20ce54f8e407d575cc2d873ffa1c09a08c2689f1](https://git.cafe/gitcafe/zed/commit/20ce54f8e407d575cc2d873ffa1c09a08c2689f1?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/300972bea37c8cc1c67804c581f62ae6ab4c040e?format=markdown)
