Print warning when microbenchmarking w/ powersave

RDTSC on Linux has so much jitter when the CPU is in powersave mode
causing things like microbenchmarks to have a 1000% margin of error
This commit is contained in:
Justine Tunney 2022-06-10 20:51:36 -07:00
parent 41c86fe86b
commit c6d8e516b2
5 changed files with 64 additions and 4 deletions

View file

@ -642,6 +642,7 @@ int LuaBenchmark(lua_State *L) {
luaL_checktype(L, 1, LUA_TFUNCTION);
count = luaL_optinteger(L, 2, 100);
maxattempts = luaL_optinteger(L, 3, 10);
__warn_if_powersave();
lua_gc(L, LUA_GCSTOP);
for (attempts = 0;;) {