summaryrefslogtreecommitdiff
path: root/tests/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2025-03-19 23:23:55 +0800
committerruki <[email protected]>2025-04-08 15:31:54 +0800
commitf8346ab6e40bdcf9506f1400f74860bbcea764ff (patch)
treef865425c73e199f314c0600d08809f8768e190c3 /tests/modules
parent6785ce5822f298ce64684548dfc9d35ec8dd5030 (diff)
improve jobgraph tests
Diffstat (limited to 'tests/modules')
-rw-r--r--tests/modules/async/run_jobgraph.lua13
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/modules/async/run_jobgraph.lua b/tests/modules/async/run_jobgraph.lua
index bcf5be2fd..ec9c9175f 100644
--- a/tests/modules/async/run_jobgraph.lua
+++ b/tests/modules/async/run_jobgraph.lua
@@ -2,22 +2,23 @@ import("core.base.scheduler")
import("async.jobgraph")
import("async.runjobs")
-function _jobfunc(job, opt)
- print("%s: run job (%s)", scheduler.co_running(), job.name)
+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 (%s) end, progress: %s, dt: %d ms", scheduler.co_running(), job.name, opt.progress, dt)
+ print("%s: run job (%d/%d) end, progress: %s, dt: %d ms", scheduler.co_running(), index, total, opt.progress, dt)
end
function main()
print("==================================== test jobpool ====================================")
local jobs = jobgraph.new()
- jobs:add_job("job/root", _jobfunc)
+ jobs:add("job/root", _jobfunc)
for i = 1, 3 do
- jobs:add_job("job/" .. i, _jobfunc)
+ jobs:add("job/" .. i, _jobfunc)
for j = 1, 50 do
- jobs:add_job("job/" .. i .. "/" .. j, _jobfunc)
+ jobs:add("job/" .. i .. "/" .. j, _jobfunc)
+ jobs:add_deps("job/" .. i .. "/" .. j, "job/" .. i, "job/root")
end
end
t = os.mclock()