docs: Add profile guide. (#1227)

This commit is contained in:
Jason Lee 2025-09-09 14:56:42 +08:00 committed by GitHub
parent 51caf932db
commit e1dede93b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -54,3 +54,25 @@ So please refer to the following UI guides when you design or change the UI comp
- Use `default` mouse cursor not `pointer` for buttons, unless it's a link button, we are building desktop apps, not web apps.
- Use `md` size for most cases and as the default.
## Profile the performance
When you change the rendering code, please profile the performance to make sure the FPS is still good.
You can use `MTL_HUD_ENABLED=1` environment variable to enable the Metal HUD to see the FPS and other performance metrics.
```bash
MTL_HUD_ENABLED=1 cargo run
```
> NOTE: Only available on macOS with Metal backend, and the FPS is up **limited your monitor refresh rate**, usually 60 or 120.
### Use Samply to profile the the performance
You can use [Samply](https://github.com/mstange/samply) to profile the performance of the application to get more detailed information.
```bash
samply record cargo run
```
Use `samply record` command to start rust development, and do some operations in the app that you want to profile, then stop the terminal with `ctrl-c`, then samply will open the browser to show the profile results.