use elapsed on instant (#4599)
# Objective - reopen #4497 on main - Make the example a tiny bit more elegant
This commit is contained in:
parent
dafd7a14c9
commit
d5e770dfcb
@ -59,7 +59,7 @@ fn spawn_tasks(mut commands: Commands, thread_pool: Res<AsyncComputeTaskPool>) {
|
||||
let mut rng = rand::thread_rng();
|
||||
let start_time = Instant::now();
|
||||
let duration = Duration::from_secs_f32(rng.gen_range(0.05..0.2));
|
||||
while Instant::now() - start_time < duration {
|
||||
while start_time.elapsed() < duration {
|
||||
// Spinning for 'duration', simulating doing hard
|
||||
// compute work generating translation coords!
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
let mut rng = rand::thread_rng();
|
||||
let start_time = Instant::now();
|
||||
let duration = Duration::from_secs_f32(rng.gen_range(0.0..0.2));
|
||||
while Instant::now() - start_time < duration {
|
||||
while start_time.elapsed() < duration {
|
||||
// Spinning for 'duration', simulating doing hard work!
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user