mirror of
https://github.com/lune-org/mlua-luau-scheduler.git
synced 2025-04-04 10:30:56 +01:00
Revert back to original benchmark
This commit is contained in:
parent
dac729cf46
commit
4a6dbba1ed
2 changed files with 6 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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<f64>| 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())
|
||||
|
|
Loading…
Add table
Reference in a new issue