Help with Benchmark.
#1

I tried to use Slice's Tutorial (https://sampforum.blast.hk/showthread.php?tid=218491) about benchmarks to do some tests. And i'm wondering if this is the right way to do them.


Код:
#define START_BENCH(%0); {new __a=%0,__b=0,__c,__d=GetTickCount(),__e=1;do{}\
	while(__d==GetTickCount());__c=GetTickCount();__d=__c;while(__c-__d<__a||\
	__e){if(__e){if(__c-__d>=__a){__e=0;__c=GetTickCount();do{}while(__c==\
	GetTickCount());__c=GetTickCount();__d=__c;__b=0;}}{
	
#define FINISH_BENCH(%0); }__b++;__c=GetTickCount();}printf(" Bench for "\
	%0": executes, by average, %.2f times/ms.",floatdiv(__b,__a));}
	
CMD:bench(playerid, params[])
{
	START_BENCH(1000);
	{
	//for (new x=1, p=MAX_GANGS; x<=p; x++)
	for (new x=1; x<MAX_GANGS; x++)
	{
	    if(DOF2_FileExists(Gang_Files(x)))
	    {
	    	strcat(GangInfo[x][Name], DOF2_GetString(Gang_Files(x), "GangName"), 32);
	  	  	GangInfo[x][IdUsed] = DOF2_GetBool(Gang_Files(x), "IdUsed");
	  	  	GangInfo[x][GangColor] = DOF2_GetHex(Gang_Files(x), "GangColor");
            GangInfo[x][GangMembers] = DOF2_GetInt(Gang_Files(x), "GangMembers");
            GangInfo[x][GangID] = DOF2_GetInt(Gang_Files(x), "GangID");
            GangInfo[x][GangRespect] = DOF2_GetInt(Gang_Files(x), "GangRespect");

	  	  //	printf("Loaded Gang %d (%s)", x, GangInfo[x][Name]);
	     }
	}
	}
	FINISH_BENCH("Test");

	return 1;
}
This piece of code is giving 4.56 times/ms. But i don't know if i'm doing it right.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)