Facepunch / garrysmod-requests

Feature requests for Garry's Mod
86 stars 24 forks source link

Add hook names to vprof #2374

Open RaphaelIT7 opened 7 months ago

RaphaelIT7 commented 7 months ago

Details

Currently, you cannot know which hooks CLuaGamemode::Call, CLuaGamemode::CallWithArgs and CLuaGamemode::CallFinish call which should be changed.
They should include the hook name in Vprof which would allow one to make it far easier to find any performance issues.
This should be relatively easy to implement and it would be really useful.

Example implementation for CLuaGamemode::CallFinish(same for other functions):

std::map<int, std::string> CallFinishStrs; // We need to save the std::string, because if it gets deleted VProf gets empty or garbage entries
void CLuaGamemode::CallFinish(int pool)
{
    if (CallFinishStrs.find(pool) == CallFinishStrs.end())
    {
        std::string vprof = gLUA->GetPooledString(pool);
        vprof = "CLuaGamemode::CallFinish (" + vprof + ")";
        CallFinishStrs[pool] = vprof;
    }

    VPROF_BUDGET( CallFinishStrs[pool].c_str(), "GMOD" );

    [...]
}
MorrowFOC commented 7 months ago

It Would be really useful !

NathanX-S commented 3 months ago

Bump