mirror of
https://github.com/lune-org/mlua-luau-scheduler.git
synced 2025-04-18 10:53:45 +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
|
for i = 1, 20 do
|
||||||
print("iteration " .. tostring(i) .. " of 5")
|
print("iteration " .. tostring(i) .. " of 20")
|
||||||
local thread = coroutine.running()
|
local thread = coroutine.running()
|
||||||
|
|
||||||
local counter = 0
|
local counter = 0
|
||||||
for j = 1, 50_000 do
|
for j = 1, 50_000 do
|
||||||
spawn(function()
|
spawn(function()
|
||||||
wait(0.1 + 0.1 * math.random())
|
wait()
|
||||||
counter += 1
|
counter += 1
|
||||||
if counter == 50_000 then
|
if counter == 50_000 then
|
||||||
print("completed iteration " .. tostring(i) .. " of 5")
|
print("completed iteration " .. tostring(i) .. " of 20")
|
||||||
spawn(thread)
|
spawn(thread)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
wait(0.1 * math.random())
|
|
||||||
|
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,8 @@ pub fn main() -> LuaResult<()> {
|
||||||
// Set up persistent lua environment
|
// Set up persistent lua environment
|
||||||
lua.globals().set(
|
lua.globals().set(
|
||||||
"wait",
|
"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 before = Instant::now();
|
||||||
let after = Timer::after(Duration::from_secs_f64(duration)).await;
|
let after = Timer::after(Duration::from_secs_f64(duration)).await;
|
||||||
Ok((after - before).as_secs_f64())
|
Ok((after - before).as_secs_f64())
|
||||||
|
|
Loading…
Add table
Reference in a new issue