SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Closed Thread
 
Thread Tools Display Modes
Old 24/09/2018, 12:30 PM   #31
corne
Huge Clucker
 
corne's Avatar
 
Join Date: Jul 2010
Location: The Netherlands
Posts: 293
Reputation: 205
Default Re: PawnPlus

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.
__________________
corne is offline  
Old 24/09/2018, 03:44 PM   #32
Danielknow
Big Clucker
 
Join Date: May 2018
Location: United States
Posts: 70
Reputation: 1
Default Re: PawnPlus

nice work.
Danielknow is offline  
Old 24/09/2018, 04:13 PM   #33
IllidanS4
Huge Clucker
 
IllidanS4's Avatar
 
Join Date: Feb 2013
Posts: 341
Reputation: 260
Default Re: PawnPlus

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.
__________________
PawnPlus
YSF
Yet Another Lua Plugin
Long Function Names
 i_quat.inc 


kingsofsa.cz:8888 running Cinematic Mode
IllidanS4 is offline  
Old 26/09/2018, 05:48 PM   #34
corne
Huge Clucker
 
corne's Avatar
 
Join Date: Jul 2010
Location: The Netherlands
Posts: 293
Reputation: 205
Default Re: PawnPlus

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.
__________________
corne is offline  
Old 26/09/2018, 09:02 PM   #35
IllidanS4
Huge Clucker
 
IllidanS4's Avatar
 
Join Date: Feb 2013
Posts: 341
Reputation: 260
Default Re: PawnPlus

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.
__________________
PawnPlus
YSF
Yet Another Lua Plugin
Long Function Names
 i_quat.inc 


kingsofsa.cz:8888 running Cinematic Mode
IllidanS4 is offline  
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Help] PawnPlus IDE Manda21 Scripting Help 4 29/10/2016 01:41 PM
[Tool/Web/Other] [0.1] PawnPlus IDE - PAWNO alternative WopsS Tools and Files 62 13/04/2016 10:32 PM
[Tool/Web/Other] PawnPlus IDE - PAWNO alternative WopsS Tools and Files 94 14/01/2016 09:32 PM


All times are GMT. The time now is 09:34 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.