ThePhD / sol2

Sol3 (sol2 v3.0) - a C++ <-> Lua API wrapper with advanced features and top notch performance - is here, and it's great! Documentation:
http://sol2.rtfd.io/
MIT License
4.06k stars 492 forks source link

Why sol3 is slower than Luabridge3 when both using LuaJIT, #1600

Open qiuxinyun2010 opened 2 months ago

qiuxinyun2010 commented 2 months ago

The test case is to sum to 10000000.

execution time:

lua.script(R"(
        x = 0;
        for i = 1, 10000000 do
            x = x+i;
        end
 )");
// sol took 56 ms
// luabridge took 7ms

int x = 0;
for (auto i = 0; i < 10000000; i++)
{
  x0 += i;
}
// took 6ms
hfn92 commented 2 months ago

did you load the jit module with lua.open_libraries(sol::lib::jit)?