local lanes = require "lanes".configure()
local timer = require "timer"
local numMsgs = arg[1] or 50000
local t = timer()
local linda = lanes.linda()
local MSG_SIZE = 1024
local msg = string.rep(0, MSG_SIZE)
local function producer(max)
for i = 1, max do
linda:send("x", msg) end
end
local a = lanes.gen("", producer)(numMsgs)
local count = 0
while true do
local key, val = linda:receive(0.01, "x") if val == nil then
break end
count = count + 1
end
local bytes = count * MSG_SIZE
local rate = math.floor((bytes / 1000000) / t:elapsed())
print("MsgCnt: " .. count .. ", CPUTime: ".. t:elapsed() ..
", Rate: " .. rate .. " MB/s")