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

[TUT] How to use an efficient debug system, which does not overload the final code


Post New Thread Reply   
 
Thread Tools Display Modes
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 05-27-2017 , 10:11   Re: [TUT] How to use an efficient debug system, which does not overload the final cod
Reply With Quote #11

Wrong, you can't define a macross with '//' it will give you error with Empty statement.

Try to compile this simple code:
PHP Code:
#include <amxmodx>

#define Test(%1) // 

public client_putinserverid )
{
    
Testid )


Last edited by Craxor; 05-27-2017 at 10:14.
Craxor is offline
Send a message via ICQ to Craxor
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 05-27-2017 , 10:16   Re: [TUT] How to use an efficient debug system, which does not overload the final cod
Reply With Quote #12

You are right. Setting the `//` as macro argument is ignored by the preprocessor.
Doing `#define LOG // things` is the same as do `#define LOG`.
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective

Last edited by addons_zz; 05-27-2017 at 10:41.
addons_zz is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 05-27-2017 , 10:18   Re: [TUT] How to use an efficient debug system, which does not overload the final cod
Reply With Quote #13

But you can do that:
PHP Code:
#include <amxmodx>

#define Test(%1) my_null()

my_null()
{

}

public 
client_putinserverid )
{
    
Testid );

Btw: ofcourse is ignored, i mean, this is the only purpose of '//' and '/*' to be ignored at compilation-time.

Last edited by Craxor; 05-27-2017 at 10:20.
Craxor is offline
Send a message via ICQ to Craxor
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 05-27-2017 , 10:21   Re: [TUT] How to use an efficient debug system, which does not overload the final cod
Reply With Quote #14

But I think it has a downside as discussed on: The choice for allow semicolons on Macros
But may be we can define some compiler flags which do optimization and remove the trashed instructions.
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective
addons_zz is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 05-27-2017 , 10:33   Re: [TUT] How to use an efficient debug system, which does not overload the final cod
Reply With Quote #15

these can bee viewed only with amxmodx profiler so it has nothing with debbuging, i mean, if somebody use your debug system will be interested only to stop debug messages wich works with empty functions, but also it will be cool to have some function for compilation time wich CommentFunctions() if a condition is true or something like that.
Craxor is offline
Send a message via ICQ to Craxor
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 05-27-2017 , 11:05   Re: [TUT] How to use an efficient debug system, which does not overload the final cod
Reply With Quote #16

Quote:
Originally Posted by Craxor View Post
these can bee viewed only with amxmodx profiler so it has nothing with debbuging
I mean, the purpose of this debugging system, is to completely disable it and remove all its instructions from the final code.
If you put `#define Test(%1) my_null()`, you will be inserting several instructions on the code.

For example, If I take the Galileo plugin latest version and use this technique:
Quote:
Originally Posted by Craxor View Post
PHP Code:
#include <amxmodx>

#define Test(%1) my_null()

my_null()
{


==
The final code will be of the size:
Code:
AMX Mod X Compiler 1.8.3-dev+5116
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2013 AMX Mod X Team

Header size:           6124 bytes
Code size:           264384 bytes
Data size:           106432 bytes
Stack/heap size:      16384 bytes
Total requirements:  393324 bytes
Done.
But if I use only:
PHP Code:
#include <amxmodx>

#define Test(%1) 
The final code has the size:
Code:
AMX Mod X Compiler 1.8.3-dev+5116
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2013 AMX Mod X Team

Header size:           6124 bytes
Code size:           240288 bytes
Data size:           106432 bytes
Stack/heap size:      16384 bytes
Total requirements:  369228 bytes
Done.
You may notice the increase from `369.228 bytes` to `393.324 bytes`.
The `.amxx` binary code increased `24.096 bytes`.

Which also insert trash instructions overhead while the plugin is running.
This is due these extra function calls which do nothing on the `.amxx` code:
Code:
    call my_null     proc    ; my_null     break   ; b0     zero.pri     retn

Quote:
Originally Posted by Craxor View Post
i mean, if somebody use your debug system will be interested only to stop debug messages wich works with empty functions, but also it will be cool to have some function for compilation time wich CommentFunctions() if a condition is true or something like that.
This is possible, the solution is specified on the other post:
Quote:
Originally Posted by addons_zz View Post
I can remove the semicolons from the macros ending, then the option:
Code:
    #define LOGGER(%1)
Will work just fine, because there will be any ': error 036: empty statement'.
You just cannot add semicolons to macro names.
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective

Last edited by addons_zz; 05-27-2017 at 11:07.
addons_zz is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 05-27-2017 , 11:58   Re: [TUT] How to use an efficient debug system, which does not overload the final cod
Reply With Quote #17

Yeah i understand, i know and i understand from the thread you linked about the interna code, that will be executed even if the function is empty, i mean not all the codes, just some codes foor empty functions, you know what i mean ... but i was trying to pinpoint something else, that this is a trivial and minimal difference, i mean, computers are much more powerfull now in nowdays, if you send empty functions to the server it will never can lead to errors, crushes, bugs, etc ... here's a test to see what i mean:

PHP Code:
#include <amxmodx>

my_null(){}

public 
plugin_init( )
{
    for( new 
01000000i++ )
    {
            
my_null();
    }

I've just made a loop from 1 to 1 milion and i call my_null() 1 milion times, the server not even fell when i change the map, insteand try to send a server_print() message or something else, i bet your server will feel the difference between these.

Last edited by Craxor; 05-27-2017 at 12:01.
Craxor is offline
Send a message via ICQ to Craxor
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 05-27-2017 , 12:27   Re: [TUT] How to use an efficient debug system, which does not overload the final cod
Reply With Quote #18

We can say them it is a matter of preference. When disabling the debugger, I prefer not add semicolons instead of adding empty function calls.
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective
addons_zz is offline
Reply



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 16:15.


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