Skip to content

Instantly share code, notes, and snippets.

View jlj's full-sized avatar

Jean-Luc Jumpertz jlj

View GitHub Profile
@jlj
jlj / lua-image-ramp-bench.lua
Created February 5, 2016 13:39
A small Lua benchmark including table creation and usage, arithmetics, function calls and upvalues
print ("Starting Lua ramp bench")
local startTime = os.clock()
do
local floor = math.floor
local function image_ramp_green(n)
local img = {}
local f = 255/(n-1)
for i=1,n do
img[i] = { red = 0, green = floor((i-1)*f), blue = 0, alpha = 255 }
@jlj
jlj / gist:9a9d4ce166092ba427ce
Last active August 29, 2015 14:14
A simple way of configuring Lua to accept the indexing of nil values
static int handleNilIndexing (lua_State* luaState)
{
return 0; // zero return values is equivalent to returning nil
}
lua_State* setupLua()
{
// Create the new lua state
lua_State* luaState = luaL_newstate();