mirror of
https://github.com/lune-org/lune.git
synced 2024-12-13 13:30:38 +00:00
More accurate task.wait benchmarks in test
This commit is contained in:
parent
d7404679c7
commit
49864eb162
1 changed files with 7 additions and 2 deletions
|
@ -1,9 +1,11 @@
|
||||||
|
local process = require("@lune/process")
|
||||||
local stdio = require("@lune/stdio")
|
local stdio = require("@lune/stdio")
|
||||||
local task = require("@lune/task")
|
local task = require("@lune/task")
|
||||||
|
|
||||||
-- Wait should be accurate down to at least 10ms
|
-- Wait should be accurate down to at least 10ms
|
||||||
|
-- on Windows, and 3ms on Linux and / or macOS
|
||||||
|
|
||||||
local EPSILON = 10 / 1_000
|
local EPSILON = if process.os == "windows" then 10 / 1_000 else 3 / 1_000
|
||||||
|
|
||||||
local function test(expected: number)
|
local function test(expected: number)
|
||||||
local start = os.clock()
|
local start = os.clock()
|
||||||
|
@ -41,7 +43,10 @@ local function measure(duration: number)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
measure(1 / 100)
|
-- About 15ms is usually the shortest sleep time on Windows, but
|
||||||
|
-- Linux and macOS can usually do down to about 5ms or less
|
||||||
|
measure(if process.os == "windows" then 15 / 1_000 else 5 / 1_000)
|
||||||
|
|
||||||
measure(1 / 60)
|
measure(1 / 60)
|
||||||
measure(1 / 30)
|
measure(1 / 30)
|
||||||
measure(1 / 20)
|
measure(1 / 20)
|
||||||
|
|
Loading…
Reference in a new issue