forked from BigfootDev/flatbuffers
[Lua] Add LuaJIT support (#6584)
* [Lua] Add LuaJIT support Here is the output of LuaTest.sh: Run with LuaJIT: built 100 512-byte flatbuffers in 0.16sec: 0.63/msec, 0.31MB/sec built 1000 512-byte flatbuffers in 0.08sec: 12.06/msec, 5.89MB/sec built 10000 512-byte flatbuffers in 0.80sec: 12.44/msec, 6.07MB/sec built 10000 512-byte flatbuffers in 0.33sec: 30.58/msec, 14.93MB/sec traversed 100 592-byte flatbuffers in 0.04sec: 2.51/msec, 1.42MB/sec traversed 1000 592-byte flatbuffers in 0.03sec: 31.52/msec, 17.79MB/sec traversed 10000 592-byte flatbuffers in 0.21sec: 48.77/msec, 27.53MB/sec Run with Lua 5.3: built 100 512-byte flatbuffers in 0.02sec: 5.44/msec, 2.66MB/sec built 1000 512-byte flatbuffers in 0.17sec: 5.74/msec, 2.80MB/sec built 10000 512-byte flatbuffers in 1.75sec: 5.72/msec, 2.79MB/sec built 10000 512-byte flatbuffers in 1.38sec: 7.26/msec, 3.55MB/sec traversed 100 592-byte flatbuffers in 0.00sec: 27.64/msec, 15.60MB/sec traversed 1000 592-byte flatbuffers in 0.03sec: 30.46/msec, 17.20MB/sec traversed 10000 592-byte flatbuffers in 0.34sec: 29.62/msec, 16.72MB/sec * [Lua] Better usage description * update according to the review
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
local compat = require("flatbuffers.compat")
|
||||
-- locals for slightly faster access
|
||||
local string_pack = compat.string_pack
|
||||
local string_unpack = compat.string_unpack
|
||||
|
||||
|
||||
local m = {} -- the module table
|
||||
|
||||
local mt = {} -- the module metatable
|
||||
@@ -104,19 +110,15 @@ function mt:Set(value, position)
|
||||
self.data[position] = value
|
||||
end
|
||||
|
||||
-- locals for slightly faster access
|
||||
local sunpack = string.unpack
|
||||
local spack = string.pack
|
||||
|
||||
-- Pack the data into a binary representation
|
||||
function m.Pack(fmt, ...)
|
||||
return spack(fmt, ...)
|
||||
return string_pack(fmt, ...)
|
||||
end
|
||||
|
||||
-- Unpack the data from a binary representation in
|
||||
-- a Lua value
|
||||
function m.Unpack(fmt, s, pos)
|
||||
return sunpack(fmt, s.str, pos + 1)
|
||||
return string_unpack(fmt, s.str, pos + 1)
|
||||
end
|
||||
|
||||
-- Return the binary array module
|
||||
|
||||
Reference in New Issue
Block a user