From 4a6dbba1ed26cd250f64b273bf9df8bc7c5bf8a8 Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Thu, 18 Jan 2024 21:59:06 +0100 Subject: [PATCH] Revert back to original benchmark --- src/main.luau | 10 ++++------ src/main.rs | 3 ++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main.luau b/src/main.luau index bfa13d2..224e240 100644 --- a/src/main.luau +++ b/src/main.luau @@ -1,20 +1,18 @@ -for i = 1, 5 do - print("iteration " .. tostring(i) .. " of 5") +for i = 1, 20 do + print("iteration " .. tostring(i) .. " of 20") local thread = coroutine.running() local counter = 0 for j = 1, 50_000 do spawn(function() - wait(0.1 + 0.1 * math.random()) + wait() counter += 1 if counter == 50_000 then - print("completed iteration " .. tostring(i) .. " of 5") + print("completed iteration " .. tostring(i) .. " of 20") spawn(thread) end end) end - wait(0.1 * math.random()) - coroutine.yield() end diff --git a/src/main.rs b/src/main.rs index 02d1429..ebed917 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,7 +19,8 @@ pub fn main() -> LuaResult<()> { // Set up persistent lua environment lua.globals().set( "wait", - lua.create_async_function(|_, duration: f64| async move { + lua.create_async_function(|_, duration: Option| async move { + let duration = duration.unwrap_or_default().min(1.0 / 250.0); let before = Instant::now(); let after = Timer::after(Duration::from_secs_f64(duration)).await; Ok((after - before).as_secs_f64())