It is currently 21 Nov 2018 23:31






Reply to topic  [ 11 posts ] 
 [TuT] Cum sa testezi eficenta si viteza unei native. 
Author Message
Membru, skill +1
Membru, skill +1
User avatar

Joined: 07 Jan 2016 09:34
Posts: 317
Detinator Steam: Da
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Cu aceste functii puteti sa testati care functie/nativa e mai eficienta/rapida, multumesc lui black rose, exemplu+functia in sine mai jos:

Code:
#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:
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!

_________________
AMXX Blue e acum doar pe github.


08 Jun 2017 16:44
Profile multumesc WWW
Membru, skill +4
Membru, skill +4
User avatar

Joined: 05 Jan 2016 19:17
Posts: 1878
Detinator Steam: Nu
Detinator server CS: Da
Reputatie: Membru Club eXtreamCS (2 luni)
Fond eXtream: 0
what, format este mai rapid ca formatex


14 Jun 2017 19:13
Profile multumesc YIM WWW
Membru, skill +1
Membru, skill +1
User avatar

Joined: 07 Jan 2016 09:34
Posts: 317
Detinator Steam: Da
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Nu conteaza functia care o folosesc ca sa formatez stockul avand in vedere ca oricum o sa scoti stock-ul pentru un plugin adevarat, folosesti stock-ul doar ca compari functii/metode intre ele.

_________________
AMXX Blue e acum doar pe github.


17 Jun 2017 09:12
Profile multumesc WWW
Membru, skill +4
Membru, skill +4
User avatar

Joined: 05 Jan 2016 19:17
Posts: 1878
Detinator Steam: Nu
Detinator server CS: Da
Reputatie: Membru Club eXtreamCS (2 luni)
Fond eXtream: 0
nu ma refeream la stockul tau, am inlocuit set_user_health( id, 250 ); si set_pev( id, pev_health, 250.0 ); cu formatex si format si format este mai rapid decat formatex


17 Jun 2017 10:53
Profile multumesc YIM WWW
Membru, skill +1
Membru, skill +1
User avatar

Joined: 07 Jan 2016 09:34
Posts: 317
Detinator Steam: Da
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
1. Totul e facut de Black Rose de pe aliedmods nu de catre mine.
2. Ca sa popuplam mai bine topicul, ai putea sa arati cum ai facut asta si OutPut-ul ? Chiar daca pot sa fac si eu asta e pentru activiteate :P

_________________
AMXX Blue e acum doar pe github.


18 Jun 2017 11:08
Profile multumesc WWW
Online
Scripter eXtreamCS
Scripter eXtreamCS

Joined: 13 Jul 2013 16:31
Posts: 1354
Detinator Steam: Da
Reputatie: Scripter eXtreamCS
Moderator ajutator
Fond eXtream: 0
JaiLBreaK wrote:
nu ma refeream la stockul tau, am inlocuit set_user_health( id, 250 ); si set_pev( id, pev_health, 250.0 ); cu formatex si format si format este mai rapid decat formatex


cum nici functia random nu e un random ci un pseudo-random, asa si functia lui
in teorie pare totul ok, nu ?
ei bine uite ca ai uitat ce se intampla in spate : procesorul poate sa efectueze mai multe operatii deodata in timpul in care dai functia aia
Image
tu ce zici ?

_________________
Fara pm-uri pentru pluginuri de zm/furien + tot ce tine de vip.


19 Jun 2017 16:55
Profile multumesc
Membru, skill +1
Membru, skill +1
User avatar

Joined: 07 Jan 2016 09:34
Posts: 317
Detinator Steam: Da
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Lux0r, teoretic :P acele functii nu sunt chemate daca el nu foloseste copy-back-ul, nu ?

Oricum optez pentru formatex().

_________________
AMXX Blue e acum doar pe github.


20 Jun 2017 00:41
Profile multumesc WWW
Membru, skill +1
Membru, skill +1
User avatar

Joined: 07 Jan 2016 09:34
Posts: 317
Detinator Steam: Da
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
o alta metoda ar fi asta:
Code:
#include <amxmodx>
#include <debug>
#include <fun>
#include <fakemeta>

new fun, fm, total, times;
const maxtimes = 5;

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

public ptest(id)
{
    new iStart1 = debug_cur_tick();
    debug_loop_fortick()
    {
        set_user_health(id, 250 );
    }
    debug_stop_tick(iStart1);

    new iStart2 = debug_cur_tick();
    debug_loop_fortick()
    {
        set_pev( id, pev_health, 250.0 );
    }
    debug_stop_tick(iStart2);

    if( debug_compare_ticks(iStart1, iStart2) == 1 )
    {
        fun++;
    }
     
    else
    {
        fm++;
    }

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

        if( times < maxtimes )
            set_task( 3.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)!


link: https://forums.alliedmods.net/showthrea ... 725&page=3

_________________
AMXX Blue e acum doar pe github.


24 Jun 2017 10:15
Profile multumesc WWW
Membru eXtream
Membru eXtream

Joined: 09 Oct 2010 12:39
Posts: 15616
Detinator Steam: Da
Reputatie: Restrictie moderator permanent
Restrictie schimbare nume
Nume anterior: Terra
Fost membru Club eXtreamCS (5 luni)
Membrul anului 2017
Fond eXtream: 0
eficienta*


24 Jun 2017 11:05
Profile multumesc
Membru, skill +1
Membru, skill +1
User avatar

Joined: 07 Jan 2016 09:34
Posts: 317
Detinator Steam: Da
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Lord Kalu wrote:
eficienta*

mersi, o sa corectez pe la anu.

_________________
AMXX Blue e acum doar pe github.


01 Jul 2017 17:42
Profile multumesc WWW
Membru eXtream
Membru eXtream

Joined: 09 Oct 2010 12:39
Posts: 15616
Detinator Steam: Da
Reputatie: Restrictie moderator permanent
Restrictie schimbare nume
Nume anterior: Terra
Fost membru Club eXtreamCS (5 luni)
Membrul anului 2017
Fond eXtream: 0
Fuffy wrote:
Lord Kalu wrote:
eficienta*

mersi, o sa corectez pe la anu.


i don't care, poti edita si peste 100 de ani eu doar ti-am atras atentia ca ai scris gresit


01 Jul 2017 23:05
Profile multumesc
Display posts from previous:  Sort by  
Reply to topic   [ 11 posts ] 

Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  

În cazul în care aveți probleme cu contul trimiteți un email sau mesaj la servicii_extream[arond]yahoo[punct]com

Powered by phpBB® Forum Software © phpBB Group