diff options
Diffstat (limited to 'tests/linda_perf.lua')
-rw-r--r-- | tests/linda_perf.lua | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/tests/linda_perf.lua b/tests/linda_perf.lua index a50e906..4d35380 100644 --- a/tests/linda_perf.lua +++ b/tests/linda_perf.lua | |||
@@ -62,12 +62,13 @@ local lane_gobbler_gen = lanes.gen( "*", {priority = 3}, gobbler) | |||
62 | local function ziva( preloop, loop, batch) | 62 | local function ziva( preloop, loop, batch) |
63 | -- prefill the linda a bit to increase fifo stress | 63 | -- prefill the linda a bit to increase fifo stress |
64 | local top = math.max( preloop, loop) | 64 | local top = math.max( preloop, loop) |
65 | local l, lane = lanes.linda() | 65 | local l = lanes.linda() |
66 | local t1 = lanes.now_secs() | 66 | local t1 = lanes.now_secs() |
67 | for i = 1, preloop do | 67 | for i = 1, preloop do |
68 | l:send( "key", i) | 68 | l:send( "key", i) |
69 | end | 69 | end |
70 | print( "stored " .. l:count( "key") .. " items in the linda before starting consumer lane") | 70 | print( "stored " .. l:count( "key") .. " items in the linda before starting consumer lane") |
71 | local lane | ||
71 | if batch > 0 then | 72 | if batch > 0 then |
72 | if l.batched then | 73 | if l.batched then |
73 | lane = lane_gobbler_gen( l, top, batch) | 74 | lane = lane_gobbler_gen( l, top, batch) |
@@ -103,6 +104,28 @@ local function ziva( preloop, loop, batch) | |||
103 | end | 104 | end |
104 | 105 | ||
105 | -- ################################################################################################# | 106 | -- ################################################################################################# |
107 | do | ||
108 | print "############################################ tests get/set" | ||
109 | -- linda:get throughput | ||
110 | local l = lanes.linda("get/set") | ||
111 | local batch = {} | ||
112 | for i = 1,1000 do | ||
113 | table.insert(batch, i) | ||
114 | end | ||
115 | for _,size in ipairs{1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987 } do | ||
116 | l:set("<->", table_unpack(batch)) | ||
117 | local count = 20000000//size | ||
118 | print("START", "get("..size..") " .. count, " times") | ||
119 | local t1 = lanes.now_secs() | ||
120 | for i = 1, 2000000/math.sqrt(size) do | ||
121 | l:get("<->", size) | ||
122 | end | ||
123 | print("DURATION = " .. lanes.now_secs() - t1 .. "\n") | ||
124 | end | ||
125 | end | ||
126 | |||
127 | do return end | ||
128 | -- ################################################################################################# | ||
106 | 129 | ||
107 | TEST1 = TEST1 or 1000 | 130 | TEST1 = TEST1 or 1000 |
108 | PREFILL1 = PREFILL1 or 10000 | 131 | PREFILL1 = PREFILL1 or 10000 |
@@ -118,8 +141,9 @@ local tests1 = | |||
118 | { PREFILL1, FILL1, 8}, | 141 | { PREFILL1, FILL1, 8}, |
119 | { PREFILL1, FILL1, 13}, | 142 | { PREFILL1, FILL1, 13}, |
120 | { PREFILL1, FILL1, 21}, | 143 | { PREFILL1, FILL1, 21}, |
121 | { PREFILL1, FILL1, 44}, | 144 | { PREFILL1, FILL1, 34}, |
122 | { PREFILL1, FILL1, 65}, | 145 | { PREFILL1, FILL1, 55}, |
146 | { PREFILL1, FILL1, 89}, | ||
123 | } | 147 | } |
124 | print "############################################ tests #1" | 148 | print "############################################ tests #1" |
125 | for i, v in ipairs( tests1) do | 149 | for i, v in ipairs( tests1) do |
@@ -194,8 +218,9 @@ local tests2 = | |||
194 | { PREFILL2, FILL2, 8}, | 218 | { PREFILL2, FILL2, 8}, |
195 | { PREFILL2, FILL2, 13}, | 219 | { PREFILL2, FILL2, 13}, |
196 | { PREFILL2, FILL2, 21}, | 220 | { PREFILL2, FILL2, 21}, |
197 | { PREFILL2, FILL2, 44}, | 221 | { PREFILL2, FILL2, 34}, |
198 | { PREFILL2, FILL2, 65}, | 222 | { PREFILL2, FILL2, 55}, |
223 | { PREFILL2, FILL2, 89}, | ||
199 | } | 224 | } |
200 | 225 | ||
201 | print "############################################ tests #2" | 226 | print "############################################ tests #2" |