Skip to content

Instantly share code, notes, and snippets.

@ArmoredPony
ArmoredPony / lqueryperformancecounter.c
Last active September 27, 2023 00:30
Simple Lua binding for QueryPerformanceCounter function from WinAPI. Returns a function, not a table.
#include "lua.h"
#include <windows.h>
static LARGE_INTEGER pc, pf;
static int queryperformancecounter(lua_State* L) {
QueryPerformanceCounter(&pc);
lua_pushnumber(L, (double)pc.QuadPart / pf.QuadPart);
return 1;
}