1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import("async.runjobs")
function test_run(total, comax)
local f = function () end
local t1 = os.mclock()
runjobs("test", f, {total = total, comax = comax})
t1 = os.mclock() - t1
local n = total
local t2 = os.mclock()
while n ~= 0 do
f()
n = n - 1
end
t2 = os.mclock() - t2
print("runjobs(%d/%d): %d ms, plain: %d ms", total, comax, t1, t2)
end
function test_run_proc(total, comax)
local f = function () os.runv(os.programfile(), {"--version"}) end
local t1 = os.mclock()
runjobs("test", f, {total = total, comax = comax})
t1 = os.mclock() - t1
print("runjobs_proc(%d/%d): %d ms", total, comax, t1)
end
function main()
test_run(10000, 1)
test_run(10000, 10)
test_run(10000, 100)
test_run_proc(1000, 10)
end
|