Raised This Month: $12 Target: $400
 3% 

[INC] debug


Post New Thread Reply   
 
Thread Tools Display Modes
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 05-30-2017 , 18:12   Re: debug.inc
Reply With Quote #21

Quote:
Originally Posted by Craxor View Post
Code:
#define debug_timer_loop(%0,%1,%2) do {\            for(new %0 = 0; %0 < 1000000; %0++)\     {\         if(%1) {\             %2;\         }\     }\ } while (is_linux_server() == 0xDEADBEEF)
You can simplify it:
Code:
#define debug_timer_loop(%0,%1,%2) for(new %0 = 0; %0 < 1000000; %0++)\     {\         if(%1) {\             %2;\         }\     }
__________________

Last edited by PRoSToTeM@; 05-30-2017 at 18:12.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 05-31-2017 , 05:35   Re: debug.inc
Reply With Quote #22

I've replaced it anyway with somethings else ... here's a test-example with the new design:


P.S.: Check the new source from the first topic.

Last edited by Craxor; 06-02-2017 at 05:06.
Craxor is offline
Send a message via ICQ to Craxor
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 06-02-2017 , 05:06   Re: debug.inc
Reply With Quote #23

Edit: These functions has been removed becuase they are not for debugging.

Difference between get_players() and loop 32 times the iterator:
PHP Code:
#include <amxmodx>
#include <debug>

public plugin_init( )
{
    
register_srvcmd"test""test" );
}


public 
test(id
{
    new 
Timer debug_time();
    
debug_loop()
    {
        for( new 
i=032i++ )
        {
            if( 
is_user_connected) )
                continue;
        }    
    }

    
debug_stop(Timer);


    new 
Timer2 debug_time();

    new 
Players[32], Num;
    
get_playersPlayersNum );

    
debug_loop()
    {
        for( new 
ii<Num;i++)
            if( 
Players[i] )
                continue;
    }
    
debug_stop(Timer2);


    new 
szPlayers[32], szLoopPlayers[32];    

    
debug_formatTimerszLoopPlayerscharsmax(szLoopPlayers) );
    
debug_formatTimer2szPlayerscharsmax(szPlayers) );

    
debug_log" Get_Players[%s] | Loop 32 players[%s]"szPlayersszLoopPlayers );
    return 
PLUGIN_HANDLED;


Get_players() was faster because was just one player on the server ( me ) the iterator was making the iteration over 32 times even if they are no players + using is_user_connected() 32 times, output:
Code:
Get_Players[00.s:029.ms] | Loop 32 players[01.s:278.ms]
 Get_Players[00.s:021.ms] | Loop 32 players[01.s:311.ms]
 Get_Players[00.s:026.ms] | Loop 32 players[01.s:282.ms]
 Get_Players[00.s:024.ms] | Loop 32 players[01.s:321.ms]
__________________
Project: Among Us

Last edited by Craxor; 06-02-2017 at 06:54.
Craxor is offline
Send a message via ICQ to Craxor
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 06-11-2017 , 07:25   Re: [INC] debug
Reply With Quote #24

update source, added a stable an quick version, also added a code example in first thread.
Craxor is offline
Send a message via ICQ to Craxor
Depresie
Veteran Member
Join Date: Nov 2013
Old 06-15-2017 , 14:07   Re: [INC] debug
Reply With Quote #25

idk, maybe just use client_print and u also get live results ?
__________________
Depresie is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 06-15-2017 , 15:01   Re: [INC] debug
Reply With Quote #26

Quote:
Originally Posted by Depresie View Post
idk, maybe just use client_print and u also get live results ?
debug_log() it is client_print() + more messages, check the inc file ... what do you mean by 'live results' ?
Craxor is offline
Send a message via ICQ to Craxor
kristi
Senior Member
Join Date: Nov 2016
Old 06-15-2017 , 19:49   Re: [INC] debug
Reply With Quote #27

Quote:
Originally Posted by Craxor View Post
Code:
SysTime: 1497193037
That doesn't look really good imo.
kristi is offline
Send a message via Skype™ to kristi
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 06-16-2017 , 01:22   Re: [INC] debug
Reply With Quote #28

That's the current systime displayed, i leave there just to see the difference in tine between messages, also it eat less memory than using time() and formating all the time the message.


edit: just for helping you, the last number( ex: '37' in the quote you write above ) are the seconds.
__________________
Project: Among Us

Last edited by Craxor; 06-16-2017 at 01:49.
Craxor is offline
Send a message via ICQ to Craxor
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 06-23-2017 , 18:47   Re: [INC] debug
Reply With Quote #29

Debugging methods, eficency , performance and memory usage.

Here's a small tuto 'how i decide wich natives are better
:

1) You can compare wich native take less memory by comparing the byte output it uses after compilation, example:


Example 1.
PHP Code:
#include <amxmodx>
#include <fun>

public plugin_init( )
{
    
register_clcmd("test","ptest");
}

public 
ptest(id)
{
    
set_user_healthid300 );

Example2
PHP Code:
#include <amxmodx>
#include <fakemeta>

public plugin_init( )
{
    
register_clcmd("test","ptest");
}

public 
ptest(id)
{
    
set_pevidpev_health300.0 );


Example 1 output(after succesfuly compilated):

Code:
Header size:            184 bytes
Code size:              152 bytes
Data size:               48 bytes
Stack/heap size:      16384 bytes; estimated max. usage=40 cells (160 bytes)
Total requirements:   16768 bytes
Example 2 output:

Code:
Header size:            188 bytes
Code size:              184 bytes
Data size:               48 bytes
Stack/heap size:      16384 bytes; estimated max. usage=40 cells (160 bytes)
Total requirements:   16804 bytes

Then you can do the bigger one ( Example 2 - Example 1 = '36' bytes less memory over used!

I know that 36 byes is absolutly trivial and not so important, but for bigger plugins and if you just are curious you can always do that.


2) By using debug.inc to compare the tickcounts used, i've made a plugin here:

PHP Code:
#include <amxmodx>
#include <debug>
#include <fun>
#include <fakemeta>

new funfmtotaltimes;
const 
maxtimes 5;

public 
plugin_init()
{
    
register_clcmd"test""ptest" );
}

public 
ptest(id)
{
    new 
iStart1 debug_cur_tick();
    
debug_loop_fortick()
    {
        
set_user_health(id250 );
    }
    
debug_stop_tick(iStart1);

    new 
iStart2 debug_cur_tick();
    
debug_loop_fortick()
    {
        
set_pevidpev_health250.0 );
    }
    
debug_stop_tick(iStart2);

    if( 
debug_compare_ticks(iStart1iStart2) == )
    {
        
fun++;
    }
    
    else
    {
        
fm++;
    }

    if( 
total 100 )
    {
        
total++;
        
ptest(id);
    }
    else
    {
        
debug_log5"%s is faster(Fun: %i , Fm: %i, Total native calls: %i)!"fun fm "set_user_health()" "set_pev(id, pev_health, ... )"funfmtotal );
        
        
fm 0;
        
fun 0;
        
total 0;
        
        
times++;

        if( 
times maxtimes )
            
set_task3.0"ptest"id );
    }
    
    return 
PLUGIN_HANDLED;

Output:
Code:
[DEBUG, SysTime: 1498256736, Map: fy_snow, Players: 1] set_user_health() is faster(Fun: 58 , Fm: 43, Total native calls: 100)!
[DEBUG, SysTime: 1498256743, Map: fy_snow, Players: 1] set_user_health() is faster(Fun: 63 , Fm: 38, Total native calls: 100)!
[DEBUG, SysTime: 1498256751, Map: fy_snow, Players: 1] set_user_health() is faster(Fun: 65 , Fm: 36, Total native calls: 100)!
[DEBUG, SysTime: 1498256758, Map: fy_snow, Players: 1] set_user_health() is faster(Fun: 64 , Fm: 37, Total native calls: 100)!
[DEBUG, SysTime: 1498256766, Map: fy_snow, Players: 1] set_user_health() is faster(Fun: 55 , Fm: 46, Total native calls: 100)!
This shows that Fun was faster 58 times and fakemeta with set_pev(id, pev_health.. 43 times from 100 times calls.
The plugin call the function 5 times and make the loop all times is necesary.
If set_user_health() is faster all the time you can say for sure that set_user_health() is much better than Fakemeta.
__________________
Project: Among Us

Last edited by Craxor; 06-23-2017 at 18:54.
Craxor is offline
Send a message via ICQ to Craxor
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 06-23-2017 , 20:51   Re: [INC] debug
Reply With Quote #30

1. That's bullshit. The set_pev() native doesn't require more memory; it's the native call that requires more memory because the assembly gets bigger as there's one additional parameter that has to be pushed to the stack. While this does introduce more instructions to be executed, this should NEVER be a deciding point of which native to use.

Last edited by klippy; 06-23-2017 at 20:51.
klippy is offline
Reply


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

Forum Jump


All times are GMT -4. The time now is 14:23.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode