[Tutorial] Benchmarking
#21

Quote:
Originally Posted by GrimR
View Post
Aha well that clears that up lol.

I still don't understand why it worked with IsPlayerConnected but not passing my enumeration array, but I will try this when I can and see if I get a better result.
Basically, the code was run way more than 499 times. That means j would go way beyond the max size of the enum array, causing an boundary overrun. IsPlayerConnected validates the argument (i.e. if larger than 499, return invalid), so it never causes any errors.
Reply
#22

Ahhh I see now, I was in such a rush to see what the results would be I didn't properly check how the define actually works.
Reply
#23

The results I have is:

if (pInfo[playerid][pConnected]) {} executed 41.62 times/ms.

if (IsPlayerConnected(playerid)) {} executed 29.71 times/ms.

I couldn't think of a simple way in PAWN to only count and check actual people online in a loop without constantly re-assigning their ID's (which would be annoying), so I thought what if I just used a simple value in the player enumeration to track it (on in onplayerconnect and off in onplayerdisconnect) and loop through the whole lot as you normally would, and it's faster .

It's a very handy tool you made!!!
Reply
#24

Nope.. I'm not really sure how to avoid them, except for:

pawn Code:
#pragma tabsize 0
Reply
#25

Just use a bunch of if's and for's

pawn Code:
#define BENCH(%0,%1) \
    for(new _i, _t = GetTickCount(), _c; _t; ) \
        if(_t != GetTickCount()) \
            for(_i = _t = GetTickCount(); _t; _i = GetTickCount()) \
                if((_i - _t) == (%0)) \
                    for(_t = GetTickCount(); _t; ) \
                        if(_t != GetTickCount()) \
                            for(_i = _t = GetTickCount(); ; ++_c, _i = GetTickCount()) \
                                if((_i - _t) == (%0)) { \
                                    printf(" Bench for " %1 ": executes, by average, %.2f times/ms.", floatdiv(_c, (%0))); \
                                    _t = 0; \
                                    break; \
                                } else
pawn Code:
BENCH(1000, "floatdiv") {
    floatdiv( 5412.4121234, 2412.1111 );
}
This will cause absolutely no warnings and does more or less the same as your macros
Reply
#26

What kind of benching you can execute with this?
Reply
#27

crash @ Pawn Compiler Library (WinXp SP3, 32bit, Intel)
Reply
#28

I tested this using SendClientMessage to All 33 times. Results show it's being run 19.5 times a ms. Isn't that too slow? If only sendclientmessage is taking so much time to execute how can someone keep it under 50 ms as you said. And yes, I've closed my being, browser and any other computer stuff before testing this.
Reply
#29

Quote:
Originally Posted by ||123||
View Post
I tested this using SendClientMessage to All 33 times. Results show it's being run 19.5 times a ms. Isn't that too slow? If only sendclientmessage is taking so much time to execute how can someone keep it under 50 ms as you said. And yes, I've closed my being, browser and any other computer stuff before testing this.
"SendClientMessage" is a very complex operation which requires a lot of processing. I could describe it but Y_Less has a perfect explanation for it:

Quote:
Originally Posted by Y_Less
View Post
What level do you want? The "playerid" parameter is used to look up the IP and port (i.e. the socket) of a player, then the colour and text information is packed in to a packet and that is sent via TCP* to the specified socket (i.e. the player). Once there, the client checks the incoming message type and calls the relevant decoding code to extract the the colour and message and uses DirectX text operations to draw to the screen. There is also code to store the current message buffer and manipulate that to add things on to the end.



* Actually, it's sent via a custom UDP protocol, but it is similar to TCP in that is ensures delivery.
Reply
#30

What is benchmark, (someone bumped an 1 year old POST)
Reply
#31

Quote:
Originally Posted by newbie scripter
View Post
What is benchmark, (someone bumped an 1 year old POST)
Benchmarking is performing a "stress test" on a set of specific functions, and performing similar tests against other functions and comparing the time results.

http://en.wikipedia.org/wiki/Benchmark_%28computing%29
Reply
#32

Does the benchmark results in Linux differ than the Windows results? (Different high/low memory usage programs)

Off-topic = 500 POST YAAAAAAAAAAY NEW GANGSTA WOOOOOHOO
Reply
#33

Well firstly I tried to run this on a more of a complexed code. the code involves destroying and creating several phone textdraws, and it gets a speed of around 19.50 per ms. its got me really worried since I wouldnt want my sever to get slow on a 300-400 database. and the posterr of this benchmarking system wrote that functiokns that are made for players to use should be around 50 times per ms.
Reply
#34

Code:
C:\Users\andrei\Desktop\Scripting SA-MP\Basic RP Script Scratch FIX\gamemodes\U1.pwn(2512) : warning 217: loose indentation
C:\Users\andrei\Desktop\Scripting SA-MP\Basic RP Script Scratch FIX\gamemodes\U1.pwn(2516) : error 017: undefined symbol "FINISH_BENCH"
C:\Users\andrei\Desktop\Scripting SA-MP\Basic RP Script Scratch FIX\gamemodes\U1.pwn(2523) : error 030: compound statement not closed at the end of file (started at line 2512)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)