Skip to content

Instantly share code, notes, and snippets.

@luastoned
Created February 21, 2017 14:52
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 luastoned/c820a5c1da76793c11d2f1acf2b28e22 to your computer and use it in GitHub Desktop.
Save luastoned/c820a5c1da76793c11d2f1acf2b28e22 to your computer and use it in GitHub Desktop.
local ffi = require("ffi")
ffi.cdef([[
int QueryPerformanceCounter(int64_t *lpPerformanceCount);
int QueryPerformanceFrequency(int64_t *lpFrequency);
]])
local function QueryPerformanceCounter(int64)
int64 = int64 or ffi.new("int64_t[1]")
ffi.C.QueryPerformanceCounter(int64)
return tonumber(int64[0])
end
local function QueryPerformanceFrequency(int64)
int64 = int64 or ffi.new("int64_t[1]")
ffi.C.QueryPerformanceFrequency(int64)
return tonumber(int64[0])
end
return {
QueryPerformanceCounter = QueryPerformanceCounter,
QueryPerformanceFrequency = QueryPerformanceFrequency,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment