An experimental, status effects-as-entities system for Bevy.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add benchmarks.

+432 -2
-2
.github/workflows/ci.yml
··· 1 1 name: CI 2 2 3 3 on: 4 - push: 5 - branches: [main] 6 4 pull_request: 7 5 branches: [main] 8 6
+208
Cargo.lock
··· 104 104 ] 105 105 106 106 [[package]] 107 + name = "alloca" 108 + version = "0.4.0" 109 + source = "registry+https://github.com/rust-lang/crates.io-index" 110 + checksum = "e5a7d05ea6aea7e9e64d25b9156ba2fee3fdd659e34e41063cd2fc7cd020d7f4" 111 + dependencies = [ 112 + "cc", 113 + ] 114 + 115 + [[package]] 107 116 name = "alsa" 108 117 version = "0.9.1" 109 118 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 166 175 dependencies = [ 167 176 "libc", 168 177 ] 178 + 179 + [[package]] 180 + name = "anes" 181 + version = "0.1.6" 182 + source = "registry+https://github.com/rust-lang/crates.io-index" 183 + checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" 184 + 185 + [[package]] 186 + name = "anstyle" 187 + version = "1.0.13" 188 + source = "registry+https://github.com/rust-lang/crates.io-index" 189 + checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" 169 190 170 191 [[package]] 171 192 name = "approx" ··· 347 368 "bevy_log", 348 369 "bevy_reflect", 349 370 "bevy_time", 371 + "criterion", 350 372 "immediate_stats", 351 373 ] 352 374 ··· 1790 1812 ] 1791 1813 1792 1814 [[package]] 1815 + name = "cast" 1816 + version = "0.3.0" 1817 + source = "registry+https://github.com/rust-lang/crates.io-index" 1818 + checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" 1819 + 1820 + [[package]] 1793 1821 name = "cc" 1794 1822 version = "1.2.49" 1795 1823 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1829 1857 checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" 1830 1858 1831 1859 [[package]] 1860 + name = "ciborium" 1861 + version = "0.2.2" 1862 + source = "registry+https://github.com/rust-lang/crates.io-index" 1863 + checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" 1864 + dependencies = [ 1865 + "ciborium-io", 1866 + "ciborium-ll", 1867 + "serde", 1868 + ] 1869 + 1870 + [[package]] 1871 + name = "ciborium-io" 1872 + version = "0.2.2" 1873 + source = "registry+https://github.com/rust-lang/crates.io-index" 1874 + checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" 1875 + 1876 + [[package]] 1877 + name = "ciborium-ll" 1878 + version = "0.2.2" 1879 + source = "registry+https://github.com/rust-lang/crates.io-index" 1880 + checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" 1881 + dependencies = [ 1882 + "ciborium-io", 1883 + "half", 1884 + ] 1885 + 1886 + [[package]] 1832 1887 name = "clang-sys" 1833 1888 version = "1.8.1" 1834 1889 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1838 1893 "libc", 1839 1894 "libloading", 1840 1895 ] 1896 + 1897 + [[package]] 1898 + name = "clap" 1899 + version = "4.6.0" 1900 + source = "registry+https://github.com/rust-lang/crates.io-index" 1901 + checksum = "b193af5b67834b676abd72466a96c1024e6a6ad978a1f484bd90b85c94041351" 1902 + dependencies = [ 1903 + "clap_builder", 1904 + ] 1905 + 1906 + [[package]] 1907 + name = "clap_builder" 1908 + version = "4.6.0" 1909 + source = "registry+https://github.com/rust-lang/crates.io-index" 1910 + checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" 1911 + dependencies = [ 1912 + "anstyle", 1913 + "clap_lex", 1914 + ] 1915 + 1916 + [[package]] 1917 + name = "clap_lex" 1918 + version = "1.1.0" 1919 + source = "registry+https://github.com/rust-lang/crates.io-index" 1920 + checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" 1841 1921 1842 1922 [[package]] 1843 1923 name = "codespan-reporting" ··· 2072 2152 ] 2073 2153 2074 2154 [[package]] 2155 + name = "criterion" 2156 + version = "0.8.2" 2157 + source = "registry+https://github.com/rust-lang/crates.io-index" 2158 + checksum = "950046b2aa2492f9a536f5f4f9a3de7b9e2476e575e05bd6c333371add4d98f3" 2159 + dependencies = [ 2160 + "alloca", 2161 + "anes", 2162 + "cast", 2163 + "ciborium", 2164 + "clap", 2165 + "criterion-plot", 2166 + "itertools 0.13.0", 2167 + "num-traits", 2168 + "oorandom", 2169 + "page_size", 2170 + "plotters", 2171 + "rayon", 2172 + "regex", 2173 + "serde", 2174 + "serde_json", 2175 + "tinytemplate", 2176 + "walkdir", 2177 + ] 2178 + 2179 + [[package]] 2180 + name = "criterion-plot" 2181 + version = "0.8.2" 2182 + source = "registry+https://github.com/rust-lang/crates.io-index" 2183 + checksum = "d8d80a2f4f5b554395e47b5d8305bc3d27813bacb73493eb1001e8f76dae29ea" 2184 + dependencies = [ 2185 + "cast", 2186 + "itertools 0.13.0", 2187 + ] 2188 + 2189 + [[package]] 2075 2190 name = "critical-section" 2076 2191 version = "1.2.0" 2077 2192 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2082 2197 version = "0.5.15" 2083 2198 source = "registry+https://github.com/rust-lang/crates.io-index" 2084 2199 checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" 2200 + dependencies = [ 2201 + "crossbeam-utils", 2202 + ] 2203 + 2204 + [[package]] 2205 + name = "crossbeam-deque" 2206 + version = "0.8.6" 2207 + source = "registry+https://github.com/rust-lang/crates.io-index" 2208 + checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" 2209 + dependencies = [ 2210 + "crossbeam-epoch", 2211 + "crossbeam-utils", 2212 + ] 2213 + 2214 + [[package]] 2215 + name = "crossbeam-epoch" 2216 + version = "0.9.18" 2217 + source = "registry+https://github.com/rust-lang/crates.io-index" 2218 + checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" 2085 2219 dependencies = [ 2086 2220 "crossbeam-utils", 2087 2221 ] ··· 3730 3864 checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" 3731 3865 3732 3866 [[package]] 3867 + name = "oorandom" 3868 + version = "11.1.5" 3869 + source = "registry+https://github.com/rust-lang/crates.io-index" 3870 + checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" 3871 + 3872 + [[package]] 3733 3873 name = "orbclient" 3734 3874 version = "0.3.49" 3735 3875 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3754 3894 checksum = "36820e9051aca1014ddc75770aab4d68bc1e9e632f0f5627c4086bc216fb583b" 3755 3895 dependencies = [ 3756 3896 "ttf-parser", 3897 + ] 3898 + 3899 + [[package]] 3900 + name = "page_size" 3901 + version = "0.6.0" 3902 + source = "registry+https://github.com/rust-lang/crates.io-index" 3903 + checksum = "30d5b2194ed13191c1999ae0704b7839fb18384fa22e49b57eeaa97d79ce40da" 3904 + dependencies = [ 3905 + "libc", 3906 + "winapi", 3757 3907 ] 3758 3908 3759 3909 [[package]] ··· 3858 4008 version = "0.3.32" 3859 4009 source = "registry+https://github.com/rust-lang/crates.io-index" 3860 4010 checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" 4011 + 4012 + [[package]] 4013 + name = "plotters" 4014 + version = "0.3.7" 4015 + source = "registry+https://github.com/rust-lang/crates.io-index" 4016 + checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" 4017 + dependencies = [ 4018 + "num-traits", 4019 + "plotters-backend", 4020 + "plotters-svg", 4021 + "wasm-bindgen", 4022 + "web-sys", 4023 + ] 4024 + 4025 + [[package]] 4026 + name = "plotters-backend" 4027 + version = "0.3.7" 4028 + source = "registry+https://github.com/rust-lang/crates.io-index" 4029 + checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" 4030 + 4031 + [[package]] 4032 + name = "plotters-svg" 4033 + version = "0.3.7" 4034 + source = "registry+https://github.com/rust-lang/crates.io-index" 4035 + checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" 4036 + dependencies = [ 4037 + "plotters-backend", 4038 + ] 3861 4039 3862 4040 [[package]] 3863 4041 name = "png" ··· 4068 4246 version = "0.6.2" 4069 4247 source = "registry+https://github.com/rust-lang/crates.io-index" 4070 4248 checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" 4249 + 4250 + [[package]] 4251 + name = "rayon" 4252 + version = "1.11.0" 4253 + source = "registry+https://github.com/rust-lang/crates.io-index" 4254 + checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f" 4255 + dependencies = [ 4256 + "either", 4257 + "rayon-core", 4258 + ] 4259 + 4260 + [[package]] 4261 + name = "rayon-core" 4262 + version = "1.13.0" 4263 + source = "registry+https://github.com/rust-lang/crates.io-index" 4264 + checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" 4265 + dependencies = [ 4266 + "crossbeam-deque", 4267 + "crossbeam-utils", 4268 + ] 4071 4269 4072 4270 [[package]] 4073 4271 name = "read-fonts" ··· 4663 4861 "arrayref", 4664 4862 "bytemuck", 4665 4863 "strict-num", 4864 + ] 4865 + 4866 + [[package]] 4867 + name = "tinytemplate" 4868 + version = "1.2.1" 4869 + source = "registry+https://github.com/rust-lang/crates.io-index" 4870 + checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" 4871 + dependencies = [ 4872 + "serde", 4873 + "serde_json", 4666 4874 ] 4667 4875 4668 4876 [[package]]
+16
Cargo.toml
··· 28 28 [dev-dependencies] 29 29 bevy = "0.18" 30 30 bevy_auto_plugin = { version = "0.9" } 31 + criterion = { version = "0.8" } 31 32 immediate_stats = { version = "0.4", features = ["bevy_auto_plugin"] } 32 33 33 34 [lints.rust] ··· 52 53 [[example]] 53 54 name = "decaying_speed_auto_plugin" 54 55 path = "examples/immediate_stats/decaying_speed_auto_plugin.rs" 56 + 57 + [[bench]] 58 + name = "baseline" 59 + path = "benches/baseline.rs" 60 + harness = false 61 + 62 + [[bench]] 63 + name = "stack_mode" 64 + path = "benches/stack_mode.rs" 65 + harness = false 66 + 67 + [[bench]] 68 + name = "insert_mode" 69 + path = "benches/insert_mode.rs" 70 + harness = false
+82
benches/baseline.rs
··· 1 + //! Benchmarks for standard Bevy equivalents of effect operations. 2 + 3 + use bevy_alchemy::{AlchemyPlugin, EffectMode, EffectedBy, Effecting}; 4 + use bevy_app::App; 5 + use bevy_ecs::name::Name; 6 + use bevy_ecs::prelude::{Component, Entity, Spawn}; 7 + use bevy_ecs::spawn::SpawnRelated; 8 + use criterion::{Criterion, criterion_group, criterion_main}; 9 + 10 + #[derive(Component)] 11 + struct BenchEffect; 12 + 13 + fn init_app() -> (App, Entity, Entity) { 14 + let mut app = App::new(); 15 + app.add_plugins(AlchemyPlugin); 16 + 17 + let target = app.world_mut().spawn(Name::new("Target")).id(); 18 + let effect = app 19 + .world_mut() 20 + .spawn(( 21 + Effecting(target), 22 + Name::new("Effect"), 23 + EffectMode::Stack, 24 + BenchEffect, 25 + )) 26 + .id(); 27 + 28 + (app, target, effect) 29 + } 30 + 31 + /// Spawning new effect, similar to `EffectMode::Stack`. 32 + fn with_related(c: &mut Criterion) { 33 + let (mut app, target, _) = init_app(); 34 + 35 + c.bench_function("Baseline `with_related`", |b| { 36 + b.iter(|| { 37 + app.world_mut() 38 + .commands() 39 + .entity(target) 40 + .with_related::<Effecting>((Name::new("Effect"), EffectMode::Stack, BenchEffect)); 41 + app.world_mut().flush(); 42 + }) 43 + }); 44 + } 45 + 46 + /// Spawning new effect, similar to `EffectMode::Stack`. 47 + fn related_spawner(c: &mut Criterion) { 48 + let (mut app, target, _) = init_app(); 49 + 50 + c.bench_function("Baseline related spawner", |b| { 51 + b.iter(|| { 52 + app.world_mut() 53 + .commands() 54 + .entity(target) 55 + .insert(EffectedBy::spawn(Spawn(( 56 + Name::new("Effect"), 57 + EffectMode::Stack, 58 + BenchEffect, 59 + )))); 60 + app.world_mut().flush(); 61 + }) 62 + }); 63 + } 64 + 65 + /// Inserting into an existing effect, similar to `EffectMode::Insert`. 66 + fn insert(c: &mut Criterion) { 67 + let (mut app, _, effect) = init_app(); 68 + 69 + c.bench_function("Baseline insert", |b| { 70 + b.iter(|| { 71 + app.world_mut().commands().entity(effect).insert(( 72 + Name::new("Effect"), 73 + EffectMode::Stack, 74 + BenchEffect, 75 + )); 76 + app.world_mut().flush(); 77 + }) 78 + }); 79 + } 80 + 81 + criterion_group!(benches, with_related, related_spawner, insert); 82 + criterion_main!(benches);
+68
benches/insert_mode.rs
··· 1 + //! Benchmarks for applying insert-mode effects. 2 + 3 + use bevy_alchemy::{AlchemyPlugin, EffectBundle, EffectCommandsExt, EffectMode, EffectedBy}; 4 + use bevy_app::App; 5 + use bevy_ecs::name::Name; 6 + use bevy_ecs::prelude::{Component, Entity, SpawnRelated}; 7 + use criterion::{Criterion, criterion_group, criterion_main}; 8 + 9 + #[derive(Component)] 10 + struct BenchEffect; 11 + 12 + fn init_app() -> (App, Entity) { 13 + let mut app = App::new(); 14 + app.add_plugins(AlchemyPlugin); 15 + 16 + let entity = app 17 + .world_mut() 18 + .spawn(( 19 + Name::new("Target"), 20 + EffectedBy::spawn(EffectBundle { 21 + name: Name::new("Effect"), 22 + mode: EffectMode::Insert, 23 + bundle: BenchEffect, 24 + }), 25 + )) 26 + .id(); 27 + 28 + (app, entity) 29 + } 30 + 31 + fn with_effect(c: &mut Criterion) { 32 + let (mut app, entity) = init_app(); 33 + 34 + c.bench_function("Insert mode matched `with_effect`", |b| { 35 + b.iter(|| { 36 + app.world_mut() 37 + .commands() 38 + .entity(entity) 39 + .with_effect(EffectBundle { 40 + name: Name::new("Effect"), 41 + mode: EffectMode::Insert, 42 + bundle: BenchEffect, 43 + }); 44 + app.world_mut().flush(); 45 + }) 46 + }); 47 + } 48 + 49 + fn related_spawner(c: &mut Criterion) { 50 + let (mut app, entity) = init_app(); 51 + 52 + c.bench_function("Insert mode matched related spawner", |b| { 53 + b.iter(|| { 54 + app.world_mut() 55 + .commands() 56 + .entity(entity) 57 + .insert(EffectedBy::spawn(EffectBundle { 58 + name: Name::new("Effect"), 59 + mode: EffectMode::Insert, 60 + bundle: BenchEffect, 61 + })); 62 + app.world_mut().flush(); 63 + }) 64 + }); 65 + } 66 + 67 + criterion_group!(benches, with_effect, related_spawner); 68 + criterion_main!(benches);
+58
benches/stack_mode.rs
··· 1 + //! Benchmarks for applying stack-mode effects. 2 + 3 + use bevy_alchemy::{AlchemyPlugin, EffectBundle, EffectCommandsExt, EffectMode, EffectedBy}; 4 + use bevy_app::App; 5 + use bevy_ecs::name::Name; 6 + use bevy_ecs::prelude::{Component, Entity, SpawnRelated}; 7 + use criterion::{Criterion, criterion_group, criterion_main}; 8 + 9 + #[derive(Component)] 10 + struct BenchEffect; 11 + 12 + fn init_app() -> (App, Entity) { 13 + let mut app = App::new(); 14 + app.add_plugins(AlchemyPlugin); 15 + 16 + let entity = app.world_mut().spawn(Name::new("Target")).id(); 17 + 18 + (app, entity) 19 + } 20 + 21 + fn with_effect(c: &mut Criterion) { 22 + let (mut app, entity) = init_app(); 23 + 24 + c.bench_function("Stack mode `with_effect`", |b| { 25 + b.iter(|| { 26 + app.world_mut() 27 + .commands() 28 + .entity(entity) 29 + .with_effect(EffectBundle { 30 + name: Name::new("Effect"), 31 + mode: EffectMode::Stack, 32 + bundle: BenchEffect, 33 + }); 34 + app.world_mut().flush(); 35 + }) 36 + }); 37 + } 38 + 39 + fn related_spawner(c: &mut Criterion) { 40 + let (mut app, entity) = init_app(); 41 + 42 + c.bench_function("Stack mode related spawner", |b| { 43 + b.iter(|| { 44 + app.world_mut() 45 + .commands() 46 + .entity(entity) 47 + .insert(EffectedBy::spawn(EffectBundle { 48 + name: Name::new("Effect"), 49 + mode: EffectMode::Stack, 50 + bundle: BenchEffect, 51 + })); 52 + app.world_mut().flush(); 53 + }) 54 + }); 55 + } 56 + 57 + criterion_group!(benches, with_effect, related_spawner); 58 + criterion_main!(benches);