#!/usr/bin/luajit -- Coroutine performance test. On the GPD MicroPC (Celeron N4120 -- running at 2485MHz) it takes 6.27-6.30 seconds to do a hundred -- million ping-pong messages, which is 63 nanoseconds per ping-pong. -- By comparison, dumbfib.S takes 684ms to compute fib(40) = -- 102334155, about 7 nanoseconds per leaf call and about 3 -- nanoseconds per call. local replier = coroutine.create(function (val) while true do val = coroutine.yield(val + 1) end end) for i = 1, 1e8 do coroutine.resume(replier, i) end print(coroutine.resume(replier, 52))