Would there be a performance difference between these iterator functions and y_iterate? I currently use your dynamic containers and tasks but still use y_iterate in my gamemode and I'm wondering if it's worth to switch when it comes to doing large loops. Will probably test it myself at some point in the future when I have the time to do so if nobody else does, but it was just something that crossed my mind.
|
I don't use YSI, so I haven't measured the difference, but I am interested in the results, if you decide to compare the containers. The containers and iterators use the standard C++ classes, with some minor overhead due to safety checks, so it still might be faster than some other Pawn implementation (like pawn-vector), but it depends on a lot of factors.
|
[19:32:44] Bench for Store string 'Haha, this is a benchmark' in a PVar.: executes, by average, 1520.13 times/ms. [19:32:46] Bench for Store string 'Haha, this is a benchmark' in a normal variable with strcat.: executes, by average, 1984.01 times/ms. [19:32:48] Bench for Store string 'Haha, this is a benchmark' in a PawnPlus map with SA-MP string.: executes, by average, 1070.41 times/ms. [19:32:50] Bench for Store string 'Haha, this is a benchmark' in a PawnPlus map with PawnPlus string.: executes, by average, 620.31 times/ms.
#include <a_samp>
#include <pawnplus>
#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));}
new teststring[50],
Map:ppteststring;
public OnFilterScriptInit()
{
ppteststring = map_new();
START_BENCH( 1000 );
{
SetSVarString("benchmark", "Haha, this is a benchmark");
}
FINISH_BENCH( "Store string 'Haha, this is a benchmark' in a PVar.");
START_BENCH( 1000 );
{
strcat(teststring, "Haha, this is a benchmark");
}
FINISH_BENCH( "Store string 'Haha, this is a benchmark' in a normal variable with strcat.");
START_BENCH( 1000 );
{
map_str_add_str(ppteststring, "benchmark", "Haha, this is a benchmark");
}
FINISH_BENCH( "Store string 'Haha, this is a benchmark' in a PawnPlus map with SA-MP string.");
START_BENCH( 1000 );
{
map_str_add(ppteststring, "benchmark", str_new("Haha, this is a benchmark"));
}
FINISH_BENCH( "Store string 'Haha, this is a benchmark' in a PawnPlus map with PawnPlus string.");
return 1;
}
Once again dissapointed, seems to be much slower than SA:MP alternatives, either that or I'm just shit at benchmarking, both are possible.
![]() |