aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/testLua
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-24 04:49:55 +1000
committerDavid Walter Seikel2012-01-24 04:49:55 +1000
commite4db02e792fdce9be06a602b3fbcbc50e07dcd7e (patch)
tree49f78e1123920f5b1ed8b25fc25381e478739127 /LuaSL/testLua
parentSome test Lua scripts for luaproc and LuaJIT. (diff)
downloadSledjHamr-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.lua61
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
12count = 0 12count = 0
13 13
14for i = 1, 10 do 14proc = [=[
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
42end
43 18
44print("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
46mainProc = [=[ 37mainProc = [=[
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
75mainProc = string.format(mainProc, count) 66for i = 1, 10 do
76result, 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
69end
70
71print("Started " .. count .. " Lua threads.")
72
73result, error_msg = luaproc.newproc(string.format(mainProc, count))
77if not result then print(error_msg) end 74if not result then print(error_msg) end
78 75
79luaproc.exit() 76luaproc.exit()