[Plugin] PawnPlus
#21

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.
Reply
#22

nice work.
Reply
#23

Quote:
Originally Posted by corne
View Post
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.
Reply
#24

Quote:
Originally Posted by IllidanS4
View Post
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.
I'm not sure how to properly benchmark loops - I tried a few different things like empty loops with a large amount of iterations and GetTickCount before and after and the results, to my surpise, were that PawnPlus is 3 or 4 times as slow as y_iterate. Although, once again I have no clue how to benchmark loops, and I dont have the code I used yesterday so that people can check if I did it right.

Today I wanted to try something else, to see whether map_str_add_str would be faster than SetSVarString, here's the results and the code.

Code:
[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.
pawn Code:
#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.
Reply
#25

Quote:
Originally Posted by corne
View Post
Once again dissapointed, seems to be much slower than SA:MP alternatives, either that or I'm just shit at benchmarking, both are possible.
Using str_new("Haha, this is a benchmark") is expected to se slower, since you are creating many instances of the same string (and computing its length every time). Using one instance will be better. strcat will eventually turn into a strlen, and SetSVarString might be faster, because both the SVar pool and the map are really small. Try benchmarking it with > 10 elements.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)