bevy/examples/stress_tests
ickshonpe 84b09b9398
Newtype Anchor (#18439)
# Objective

The `Anchor` component doesn't need to be a enum. The variants are just
mapped to `Vec2`s so it could be changed to a newtype with associated
const values, saving the space needed for the discriminator by the enum.

Also there was no benefit I think in hiding the underlying `Vec2`
representation of `Anchor`s.

Suggested by @atlv24.

Fixes #18459
Fixes #18460

## Solution

Change `Anchor` to a struct newtyping a `Vec2`, and its variants into
associated constants.

## Migration Guide

The anchor component has been changed from an enum to a struct newtyping
a `Vec2`. The `Custom` variant has been removed, instead to construct a
custom `Anchor` use its tuple constructor:
```rust
Sprite {
     anchor: Anchor(Vec2::new(0.25, 0.4)),
     ..default()
}
```
The other enum variants have been replaced with corresponding constants:
* `Anchor::BottomLeft` to `Anchor::BOTTOM_LEFT`
* `Anchor::Center` to `Anchor::CENTER`
* `Anchor::TopRight` to `Anchor::TOP_RIGHT`
* .. and so on for the remaining variants
2025-03-21 22:27:11 +00:00
..
bevymark.rs Make Query::single (and friends) return a Result (#18082) 2025-03-02 19:51:56 +00:00
many_animated_sprites.rs Upgrade to Rust Edition 2024 (#17967) 2025-02-24 03:54:47 +00:00
many_buttons.rs many-cameras option for many_buttons (#17935) 2025-03-10 21:23:31 +00:00
many_cameras_lights.rs Make Query::single (and friends) return a Result (#18082) 2025-03-02 19:51:56 +00:00
many_components.rs many_components stress test improvements (#16913) 2025-02-10 21:13:57 +00:00
many_cubes.rs Upgrade to Rust Edition 2024 (#17967) 2025-02-24 03:54:47 +00:00
many_foxes.rs Allow users to customize history length in FrameTimeDiagnosticsPlugin (#17259) 2025-01-12 18:18:14 +00:00
many_gizmos.rs Allow users to customize history length in FrameTimeDiagnosticsPlugin (#17259) 2025-01-12 18:18:14 +00:00
many_glyphs.rs Newtype Anchor (#18439) 2025-03-21 22:27:11 +00:00
many_lights.rs Allow users to customize history length in FrameTimeDiagnosticsPlugin (#17259) 2025-01-12 18:18:14 +00:00
many_materials.rs Add many_materials stress test (#17346) 2025-01-24 05:46:23 +00:00
many_sprites.rs Upgrade to Rust Edition 2024 (#17967) 2025-02-24 03:54:47 +00:00
many_text2d.rs Make Query::single (and friends) return a Result (#18082) 2025-03-02 19:51:56 +00:00
README.md
text_pipeline.rs Allow users to customize history length in FrameTimeDiagnosticsPlugin (#17259) 2025-01-12 18:18:14 +00:00
transform_hierarchy.rs Upgrade to Rust Edition 2024 (#17967) 2025-02-24 03:54:47 +00:00
warning_string.txt

Stress tests

These examples are used to stress test Bevy's performance in various ways. These should be run with the "stress-test" profile to accurately represent performance in production, otherwise they will run in cargo's default "dev" profile which is very slow.

Example Command

cargo run --profile stress-test --example <EXAMPLE>