Zeex / sampgdk

Write SA-MP gamemodes in C/C++
http://zeex.github.io/sampgdk
Apache License 2.0
153 stars 83 forks source link

Slow public function call #217

Open RodrigoMSR opened 2 years ago

RodrigoMSR commented 2 years ago

I ran some tests and realized that sampgdk hooks make public function calls 4 times slower, wouldn't it be possible to further optimize these hooks? I understand if that's not possible, I'm just raising the question.

The streamer plugin uses sampgdk, that's why I noticed this difference.

Zeex commented 1 year ago

Can you attach the code of your tests so that I could try it myself?

RodrigoMSR commented 1 year ago

Code:

#include <a_samp>

main()
{
    SetTimer("TestCallTime", 1000, true);
}

forward TestCallTime();
public TestCallTime()
{
    new tick = GetTickCount();

    for(new i = 0; i < 1000000; i++)
    {
        CallLocalFunction("TestPublic", "");
    }

    printf("%dms", GetTickCount() - tick);
    return 1;
}

forward TestPublic();
public TestPublic()
{
    return 1;
}

Results: ~120ms without plugins ~730ms with streamer plugin (v2.9.5)