bevy/examples/stress_tests
Christopher Durham c19aa5939d Add Exponential Moving Average into diagnostics (#4992)
# Objective

- Add Time-Adjusted Rolling EMA-based smoothing to diagnostics.
- Closes #4983; see that issue for more more information.

## Terms

- EMA - [Exponential Moving Average](https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average)
- SMA - [Simple Moving Average](https://en.wikipedia.org/wiki/Moving_average#Simple_moving_average)

## Solution

- We use a fairly standard approximation of a true EMA where $EMA_{\text{frame}} = EMA_{\text{previous}} + \alpha \left( x_{\text{frame}} - EMA_{\text{previous}} \right)$ where $\alpha = \Delta t / \tau$ and $\tau$ is an arbitrary smoothness factor. (See #4983 for more discussion of the math.)
- The smoothness factor is here defaulted to $2 / 21$; this was chosen fairly arbitrarily as supposedly related to the existing 20-bucket SMA.
- The smoothness factor can be set on a per-diagnostic basis via `Diagnostic::with_smoothing_factor`.

---

## Changelog

### Added

- `Diagnostic::smoothed` - provides an exponentially smoothed view of a recorded diagnostic, to e.g. reduce jitter in frametime readings.

### Changed
- `LogDiagnosticsPlugin` now records the smoothed value rather than the raw value.
  - For diagnostics recorded less often than every 0.1 seconds, this change to defaults will have no visible effect.
  - For discrete diagnostics where this smoothing is not desirable, set a smoothing factor of 0 to disable smoothing.
  - The average of the recent history is still shown when available.
2022-10-24 13:46:37 +00:00
..
bevymark.rs Add Exponential Moving Average into diagnostics (#4992) 2022-10-24 13:46:37 +00:00
many_animated_sprites.rs Replace the bool argument of Timer with TimerMode (#6247) 2022-10-17 13:47:01 +00:00
many_buttons.rs Example cleanup (#6131) 2022-09-30 13:25:27 +00:00
many_cubes.rs Replace the bool argument of Timer with TimerMode (#6247) 2022-10-17 13:47:01 +00:00
many_foxes.rs Use SpatialBundle/TransformBundle in examples (#6002) 2022-10-13 12:53:18 +00:00
many_lights.rs Replace the bool argument of Timer with TimerMode (#6247) 2022-10-17 13:47:01 +00:00
many_sprites.rs Replace the bool argument of Timer with TimerMode (#6247) 2022-10-17 13:47:01 +00:00
README.md Added performance warning when running stress test examples in debug mode (#5029) 2022-07-13 19:13:46 +00:00
transform_hierarchy.rs Use SpatialBundle/TransformBundle in examples (#6002) 2022-10-13 12:53:18 +00:00
warning_string.txt Added performance warning when running stress test examples in debug mode (#5029) 2022-07-13 19:13:46 +00:00

Stress tests

These examples are used to stress test Bevy's performance in various ways. These should be run with the --release argument to cargo or equivalent optimization, otherwise they will be very slow.