diff options
author | David Walter Seikel | 2012-01-24 04:49:55 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-24 04:49:55 +1000 |
commit | e4db02e792fdce9be06a602b3fbcbc50e07dcd7e (patch) | |
tree | 49f78e1123920f5b1ed8b25fc25381e478739127 /LuaSL/testLua | |
parent | Some test Lua scripts for luaproc and LuaJIT. (diff) | |
download | SledjHamr-e4db02e792fdce9be06a602b3fbcbc50e07dcd7e.zip SledjHamr-e4db02e792fdce9be06a602b3fbcbc50e07dcd7e.tar.gz SledjHamr-e4db02e792fdce9be06a602b3fbcbc50e07dcd7e.tar.bz2 SledjHamr-e4db02e792fdce9be06a602b3fbcbc50e07dcd7e.tar.xz |
Rearrange the big test multitasking test script to be prettier.
Diffstat (limited to 'LuaSL/testLua')
-rw-r--r-- | LuaSL/testLua/luaprocTest2.lua | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/LuaSL/testLua/luaprocTest2.lua b/LuaSL/testLua/luaprocTest2.lua index 7814e42..07a3dc8 100644 --- a/LuaSL/testLua/luaprocTest2.lua +++ b/LuaSL/testLua/luaprocTest2.lua | |||
@@ -11,37 +11,28 @@ if not result then print(error_msg) end | |||
11 | 11 | ||
12 | count = 0 | 12 | count = 0 |
13 | 13 | ||
14 | for i = 1, 10 do | 14 | proc = [=[ |
15 | local proc = [=[ | 15 | require "string" |
16 | require "string" | 16 | local channel = "channel%d" |
17 | local channel = "channel%d" | 17 | local message |
18 | local message | ||
19 | |||
20 | result, error_msg = luaproc.newchannel(channel) | ||
21 | if not result then print(error_msg) end | ||
22 | repeat | ||
23 | message = luaproc.receive(channel) | ||
24 | local x, y = string.find(message, "@") | ||
25 | if not x then | ||
26 | x, y = string.find(message, "@") | ||
27 | x, y = string.find(message, "@") | ||
28 | x, y = string.find(message, "@") | ||
29 | x, y = string.find(message, "@") | ||
30 | x, y = string.find(message, "@") | ||
31 | x, y = string.find(message, "@") | ||
32 | x, y = string.find(message, "@") | ||
33 | x, y = string.find(message, "@") | ||
34 | end | ||
35 | until "quit" == message | ||
36 | ]=] | ||
37 | |||
38 | proc = string.format(proc, i) | ||
39 | -- print(proc) | ||
40 | result, error_msg = luaproc.newproc(proc) | ||
41 | if not result then print(error_msg) else count = count + 1 end | ||
42 | end | ||
43 | 18 | ||
44 | print("Started " .. count .. " Lua threads.") | 19 | result, error_msg = luaproc.newchannel(channel) |
20 | if not result then print(error_msg) end | ||
21 | repeat | ||
22 | message = luaproc.receive(channel) | ||
23 | local x, y = string.find(message, "@") | ||
24 | if not x then | ||
25 | x, y = string.find(message, "@") | ||
26 | x, y = string.find(message, "@") | ||
27 | x, y = string.find(message, "@") | ||
28 | x, y = string.find(message, "@") | ||
29 | x, y = string.find(message, "@") | ||
30 | x, y = string.find(message, "@") | ||
31 | x, y = string.find(message, "@") | ||
32 | x, y = string.find(message, "@") | ||
33 | end | ||
34 | until "quit" == message | ||
35 | ]=] | ||
45 | 36 | ||
46 | mainProc = [=[ | 37 | mainProc = [=[ |
47 | local count = %d | 38 | local count = %d |
@@ -72,8 +63,14 @@ mainProc = [=[ | |||
72 | print("Sent " .. messages .. " messages totalling " .. length .. " bytes. The largest message was " .. #message .. " bytes.") | 63 | print("Sent " .. messages .. " messages totalling " .. length .. " bytes. The largest message was " .. #message .. " bytes.") |
73 | ]=] | 64 | ]=] |
74 | 65 | ||
75 | mainProc = string.format(mainProc, count) | 66 | for i = 1, 10 do |
76 | result, error_msg = luaproc.newproc(mainProc) | 67 | result, error_msg = luaproc.newproc(string.format(proc, i)) |
68 | if not result then print(error_msg) else count = count + 1 end | ||
69 | end | ||
70 | |||
71 | print("Started " .. count .. " Lua threads.") | ||
72 | |||
73 | result, error_msg = luaproc.newproc(string.format(mainProc, count)) | ||
77 | if not result then print(error_msg) end | 74 | if not result then print(error_msg) end |
78 | 75 | ||
79 | luaproc.exit() | 76 | luaproc.exit() |