Skip to content

Instantly share code, notes, and snippets.

@nbhatti
Forked from tylerneylon/simple_lua_profile.lua
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbhatti/506cd0e568888df938f3 to your computer and use it in GitHub Desktop.
Save nbhatti/506cd0e568888df938f3 to your computer and use it in GitHub Desktop.
local t_sum = 0
local t_num = 0
local t1, t2, t3
local do_time = true
local function mark1()
if not do_time then return end
t1 = os.clock()
end
local function mark2()
if not do_time then return end
t2 = os.clock()
end
local function mark3()
if not do_time then return end
t3 = os.clock()
print('---')
print(string.format('t1-t3 took %gs', t3 - t1))
print(string.format('t1-t2 took %gs', t2 - t1))
print(string.format('t2-t3 took %gs', t3 - t2))
t_sum = t_sum + t3 - t1
t_num = t_num + 1
print(string.format('avg t1-t3 is now %gs', t_sum / t_num))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment