Code: Select all
#include <amxmodx>
#include <fun>
#include <fakemeta>
#define debug_start() tickcount()
#define debug_stop(%0) ( %0 = tickcount() - %0 )
#define debug_loop() for( new x; x < 1000000; x++ )
#define TimerSeconds(%0) ( %0 / 1000 % 60 )
#define TimerMilliseconds(%0) ( %0 % 1000 )
stock TimerConvert( timer, sztimer[], maxchars=0 )
{
formatex( sztimer, maxchars, "%02d seconds, %03d miliseconds.", TimerSeconds(timer) , TimerMilliseconds(timer) );
}
new gTest1, gTest2;
public plugin_init( )
{
register_clcmd( "say /test" , "test" );
register_clcmd( "say /test2", "test2" );
register_clcmd( "say /result", "res" );
}
public test( id )
{
new iTimer = debug_start();
debug_loop()
{
set_user_health( id, 250 );
}
debug_stop(iTimer );
gTest1 = iTimer;
return PLUGIN_HANDLED;
}
public test2( id )
{
new iTimer = debug_start();
debug_loop()
{
set_pev( id, pev_health, 250.0 );
}
debug_stop(iTimer );
gTest2 = iTimer;
return PLUGIN_HANDLED;
}
public res( id )
{
new szTimer1[40];
TimerConvert( gTest1, szTimer1, charsmax(szTimer1) );
new szTimer2[40];
TimerConvert( gTest2, szTimer2, charsmax(szTimer2) );
client_print( id, print_chat, "Fun set_user_health run in: %s", szTimer1 );
client_print( id, print_chat, "FakeMeta set_pev pev_heath run in: %s", szTimer2 );
client_print( id, print_chat, "%s is much faster!", gTest1 > gTest2 ? "Fakemeta" : "Fun" );
return PLUGIN_HANDLED;
}
Rezultat:
Code: Select all
Fun set_user_health run in: 00 seconds, 202 miliseconds.
FakeMeta set_pev pev_heath run in: 00 seconds, 390 miliseconds.
Fun is much faster!