EmbarkStudios / EmbarkStudios/puffin
Profile unit tests
- Dominant language
- Rust
- Stars
- 1.7k
- Forks
- 111
- Avg merge
- 2h 50m
- Merged PRs (30d)
- 1
Description
I want to use puffin to profile my tests but am having problems getting the viewer to catch the single frame it produces. It might be related to #85. I've had it somewhat working but that was a few versions of puffin ago.
My tests looks like this right now and I would be happy if something similar worked:
```rs
#[test]
fn test_ik_solver_neutral() -> hotham::anyhow::Result<()> {
let _ = start_puffin_server();
puffin::profile_function!();
test_ik_solver(
include_str!("../../test_data/inverse_kinematics_snapshot_2023-04-12_22.23.47.json"),
None,
)
}
```
The function `start_puffin_server` is something I wrote to create a `puffin_http::Server` and keep it alive until the test is done. It calls `puffin::GlobalProfiler::lock().new_frame();` when created and dropped. I would like to use something like `puffin::profile_unit_test!();` instead. Writing to disk is an option but I would prefer if I can keep the viewer running and update automatically as I change the code and run the test again.
Contributor guide
Research direction
Start by tracing the test entry points in the example: start_puffin_server, puffin::GlobalProfiler::lock().new_frame(), puffin::profile_function!(), and puffin_http::Server. Reproduce the single-frame test with the viewer running, then determine what a puffin::profile_unit_test!() API would need to do so rerunning the test updates the viewer automatically.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100