sampgdk icon indicating copy to clipboard operation
sampgdk copied to clipboard

Slow public function call

Open RodrigoMSR opened this issue 4 years ago • 2 comments

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.

RodrigoMSR avatar Aug 15 '21 19:08 RodrigoMSR

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

Zeex avatar Jul 10 '22 06:07 Zeex

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)

RodrigoMSR avatar Jul 10 '22 14:07 RodrigoMSR