Skip to content

Commit 634c069

Browse files
committed
clean out assets in benchmark
1 parent 9777e79 commit 634c069

File tree

1 file changed

+12
-4
lines changed
  • crates/testing_crates/script_integration_test_harness/src

1 file changed

+12
-4
lines changed

crates/testing_crates/script_integration_test_harness/src/lib.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,12 @@ pub fn run_plugin_script_load_benchmark<
359359

360360
let world_ptr = app.world_mut() as *mut World;
361361
let world_guard = Mutex::<()>::new(());
362-
let mut idx = 0;
363362
criterion.bench_function(benchmark_id, |c| {
364363
c.iter_batched(
365364
|| {
366-
idx += 1;
367365
let mut rng = RNG.lock().unwrap();
368366
let is_reload = rng.random_range(0f32..=1f32) < reload_probability;
367+
369368
// println!("Setup {idx}, {is_reload}");
370369
let guard = world_guard.lock().unwrap();
371370
// Safety: we claimed a unique guard, only code accessing this will need to do the same
@@ -382,10 +381,19 @@ pub fn run_plugin_script_load_benchmark<
382381
language: P::LANGUAGE,
383382
})
384383
});
385-
drop(guard);
386-
// run track assets (lives in PreUpdate), so handles can be dropped internally
387384
// otherwise causes random overflows due to a u16 tracking strong handles
385+
386+
// also remove assets apart from the first two
387+
assets
388+
.ids()
389+
.skip(2)
390+
.collect::<Vec<_>>()
391+
.into_iter()
392+
.for_each(|asset| _ = assets.remove(asset));
393+
394+
// run track assets (lives in PreUpdate), so handles can be dropped internally
388395
world.run_schedule(PreUpdate);
396+
drop(guard);
389397

390398
// We manually load the script inside a command.
391399
(

0 commit comments

Comments
 (0)