aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/testLua/luaprocTest2.lua
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-24 04:43:09 +1000
committerDavid Walter Seikel2012-01-24 04:43:09 +1000
commit9ecaec865008b764c27aa5476ed7b51d80dbd22b (patch)
tree012e2157f1d3b646d0492be17f951a1190680f67 /LuaSL/testLua/luaprocTest2.lua
parentTurn on some of the good stuff in LuaJIT. (diff)
downloadSledjHamr-9ecaec865008b764c27aa5476ed7b51d80dbd22b.zip
SledjHamr-9ecaec865008b764c27aa5476ed7b51d80dbd22b.tar.gz
SledjHamr-9ecaec865008b764c27aa5476ed7b51d80dbd22b.tar.bz2
SledjHamr-9ecaec865008b764c27aa5476ed7b51d80dbd22b.tar.xz
Some test Lua scripts for luaproc and LuaJIT.
Diffstat (limited to '')
-rw-r--r--LuaSL/testLua/luaprocTest2.lua80
1 files changed, 80 insertions, 0 deletions
diff --git a/LuaSL/testLua/luaprocTest2.lua b/LuaSL/testLua/luaprocTest2.lua
new file mode 100644
index 0000000..7814e42
--- /dev/null
+++ b/LuaSL/testLua/luaprocTest2.lua
@@ -0,0 +1,80 @@
1require "luaproc"
2
3result, error_msg = luaproc.createworker()
4if not result then print(error_msg) end
5result, error_msg = luaproc.createworker()
6if not result then print(error_msg) end
7result, error_msg = luaproc.createworker()
8if not result then print(error_msg) end
9result, error_msg = luaproc.createworker()
10if not result then print(error_msg) end
11
12count = 0
13
14for i = 1, 10 do
15 local proc = [=[
16 require "string"
17 local channel = "channel%d"
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
44print("Started " .. count .. " Lua threads.")
45
46mainProc = [=[
47 local count = %d
48 local messages = 0
49 local length = 0
50 local message = "This is a test message. 56789 12"
51
52 if 0 ~= count then
53 for k = 0, 16 do
54 for j = 0, 199 do
55 for i = 1, count do
56 result, error_msg = luaproc.send("channel" .. i, message)
57 if not result then print(error_msg .. " " .. i) else
58 messages = messages + 1
59 length = length + #message
60 end
61 end
62 end
63 message = message .. message
64 end
65
66 for i = 1, count do
67 result, error_msg = luaproc.send("channel" .. i, "quit")
68 if not result then print(error_msg .. " " .. i) end
69 end
70 end
71
72 print("Sent " .. messages .. " messages totalling " .. length .. " bytes. The largest message was " .. #message .. " bytes.")
73]=]
74
75mainProc = string.format(mainProc, count)
76result, error_msg = luaproc.newproc(mainProc)
77if not result then print(error_msg) end
78
79luaproc.exit()
80