diff options
Diffstat (limited to 'tests/linda_perf.lua')
-rw-r--r-- | tests/linda_perf.lua | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/tests/linda_perf.lua b/tests/linda_perf.lua index bba1408..e68d552 100644 --- a/tests/linda_perf.lua +++ b/tests/linda_perf.lua | |||
@@ -22,7 +22,7 @@ if true then | |||
22 | do | 22 | do |
23 | print "############################################ tests get/set" | 23 | print "############################################ tests get/set" |
24 | -- linda:get throughput | 24 | -- linda:get throughput |
25 | local l = lanes.linda("get/set", 1) | 25 | local l = lanes.linda{name = "get/set", group = 1} |
26 | local batch = {} | 26 | local batch = {} |
27 | for i = 1,1000 do | 27 | for i = 1,1000 do |
28 | table.insert(batch, i) | 28 | table.insert(batch, i) |
@@ -56,7 +56,7 @@ local eater = function( l, loop) | |||
56 | -- print "loop is over" | 56 | -- print "loop is over" |
57 | key, val = l:receive( "done") | 57 | key, val = l:receive( "done") |
58 | print("eater: done ("..val..")") | 58 | print("eater: done ("..val..")") |
59 | return true | 59 | return "ate everything" |
60 | end | 60 | end |
61 | 61 | ||
62 | -- ################################################################################################# | 62 | -- ################################################################################################# |
@@ -68,13 +68,13 @@ local gobbler = function( l, loop, batch) | |||
68 | l:receive( "go") | 68 | l:receive( "go") |
69 | -- eat data in batches | 69 | -- eat data in batches |
70 | for i = 1, loop/batch do | 70 | for i = 1, loop/batch do |
71 | l:receive( l.batched, "key", batch) | 71 | l:receive_batched("key", batch) |
72 | -- print("gobbler:", batch) | 72 | -- print("gobbler:", batch) |
73 | end | 73 | end |
74 | print "loop is over" | 74 | print "loop is over" |
75 | key, val = l:receive( "done") | 75 | key, val = l:receive( "done") |
76 | print("gobbler: done ("..val..")") | 76 | print("gobbler: done ("..val..")") |
77 | return true | 77 | return "gobbled everything" |
78 | end | 78 | end |
79 | 79 | ||
80 | -- ################################################################################################# | 80 | -- ################################################################################################# |
@@ -90,7 +90,7 @@ local group_uid = 1 | |||
90 | local function ziva1( preloop, loop, batch) | 90 | local function ziva1( preloop, loop, batch) |
91 | -- prefill the linda a bit to increase fifo stress | 91 | -- prefill the linda a bit to increase fifo stress |
92 | local top = math.max( preloop, loop) | 92 | local top = math.max( preloop, loop) |
93 | local l = lanes.linda("ziva1("..preloop..":"..loop..":"..batch..")", group_uid) | 93 | local l = lanes.linda{name = "ziva1("..preloop..":"..loop..":"..batch..")", group = group_uid} |
94 | group_uid = (group_uid % config.nb_user_keepers) + 1 | 94 | group_uid = (group_uid % config.nb_user_keepers) + 1 |
95 | local t1 = lanes.now_secs() | 95 | local t1 = lanes.now_secs() |
96 | for i = 1, preloop do | 96 | for i = 1, preloop do |
@@ -123,7 +123,8 @@ local function ziva1( preloop, loop, batch) | |||
123 | end | 123 | end |
124 | end | 124 | end |
125 | l:send( "done" ,"are you happy?") | 125 | l:send( "done" ,"are you happy?") |
126 | lane:join() | 126 | local r, ret = lane:join() |
127 | assert(r == true and type(ret) == "string", "got " .. tostring(r) .. " " .. tostring(ret)) | ||
127 | return lanes.now_secs() - t1 | 128 | return lanes.now_secs() - t1 |
128 | end | 129 | end |
129 | 130 | ||
@@ -165,12 +166,12 @@ end | |||
165 | 166 | ||
166 | -- sequential write/read (no parallelization involved) | 167 | -- sequential write/read (no parallelization involved) |
167 | local function ziva2( preloop, loop, batch) | 168 | local function ziva2( preloop, loop, batch) |
168 | local l = lanes.linda("ziva2("..preloop..":"..loop..":"..tostring(batch)..")", group_uid) | 169 | local l = lanes.linda{name = "ziva2("..preloop..":"..loop..":"..tostring(batch)..")", group = group_uid} |
169 | group_uid = (group_uid % config.nb_user_keepers) + 1 | 170 | group_uid = (group_uid % config.nb_user_keepers) + 1 |
170 | -- prefill the linda a bit to increase fifo stress | 171 | -- prefill the linda a bit to increase fifo stress |
171 | local top, step = math.max( preloop, loop), (l.batched and batch) and batch or 1 | 172 | local top, step = math.max( preloop, loop), batch or 1 |
172 | local batch_send, batch_read | 173 | local batch_send, batch_read |
173 | if l.batched and batch then | 174 | if batch then |
174 | local batch_values = {} | 175 | local batch_values = {} |
175 | for i = 1, batch do | 176 | for i = 1, batch do |
176 | table.insert( batch_values, i) | 177 | table.insert( batch_values, i) |
@@ -180,7 +181,7 @@ local function ziva2( preloop, loop, batch) | |||
180 | l:send( "key", table_unpack( batch_values)) | 181 | l:send( "key", table_unpack( batch_values)) |
181 | end | 182 | end |
182 | batch_read = function() | 183 | batch_read = function() |
183 | l:receive( l.batched, "key", batch) | 184 | l:receive_batched("key", batch) |
184 | end | 185 | end |
185 | else -- not batched | 186 | else -- not batched |
186 | batch_send = function() | 187 | batch_send = function() |