summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorruki <[email protected]>2024-03-18 23:44:06 +0800
committerruki <[email protected]>2024-03-18 23:44:06 +0800
commitca16db30058d8a512d73a7bee28e57f72de4c338 (patch)
tree37f034b25bf468297daa0ec4bc8dd5490f380c5e /tests
parentef76c91d0517361173246f6ee62b3b6c3ba1e29e (diff)
improve progress
Diffstat (limited to 'tests')
-rw-r--r--tests/modules/scheduler/runjobs.lua16
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/modules/scheduler/runjobs.lua b/tests/modules/scheduler/runjobs.lua
index d84f23152..4e2a98cc0 100644
--- a/tests/modules/scheduler/runjobs.lua
+++ b/tests/modules/scheduler/runjobs.lua
@@ -2,12 +2,12 @@ import("core.base.scheduler")
import("private.async.jobpool")
import("async.runjobs")
-function _jobfunc(index, total)
+function _jobfunc(index, total, opt)
print("%s: run job (%d/%d)", scheduler.co_running(), index, total)
local dt = os.mclock()
os.sleep(1000)
dt = os.mclock() - dt
- print("%s: run job (%d/%d) end, dt: %d ms", scheduler.co_running(), index, total, dt)
+ print("%s: run job (%d/%d) end, progress: %s, dt: %d ms", scheduler.co_running(), index, total, opt.progress, dt)
end
function main()
@@ -22,16 +22,16 @@ function main()
-- test jobs
print("==================================== test jobs ====================================")
local jobs = jobpool.new()
- local root = jobs:addjob("job/root", function (idx, total)
- _jobfunc(idx, total)
+ local root = jobs:addjob("job/root", function (index, total, opt)
+ _jobfunc(index, total, opt)
end)
for i = 1, 3 do
- local job = jobs:addjob("job/" .. i, function (idx, total)
- _jobfunc(idx, total)
+ local job = jobs:addjob("job/" .. i, function (index, total, opt)
+ _jobfunc(index, total, opt)
end, {rootjob = root})
for j = 1, 50 do
- jobs:addjob("job/" .. i .. "/" .. j, function (idx, total)
- _jobfunc(idx, total)
+ jobs:addjob("job/" .. i .. "/" .. j, function (index, total, opt)
+ _jobfunc(index, total, opt)
end, {rootjob = job})
end
end