[Tutorial] How to: Testes de velocidade
#1

How to:
Testes de Velocidade


O Que sгo?

Os Testes de velocidade sгo testes lуgicos, servem para testar determinados cуdigos, por exemplo, quer saber se o seu processador de comandos й mais rбpido que o ZCMD, assim saberб se compensa usar o seu processador de comandos, entгo esses testes servem para isso, testar cуdigos.

Como fazer?

Existe vбrias maneiras de fazer um teste destes, lembrando que os testes dependem da lуgica de cada um como obvio, mas irei mostrar um teste que fiz para determinar qual era o loop mais rбpido (for, while ou do).

pawn Код:
forward ForTest(); public ForTest() {
    new tick;
   
    print("- Starting Test(For)");
       
    tick=GetTickCount();
    for(new i; i < 5; i++){    
        printf("%d",i);
    }    
    printf("(FOR) Tempo: %d ms", GetTickCount()-tick);
}
forward WhileTest(); public WhileTest() {
    new tick, i;
   
    print("- Starting Test(While)");
       
    tick=GetTickCount();    
    while(i < 5){    
        printf("%d",i);        
        i++;
    }    
    printf("(While) Tempo: %d ms", GetTickCount()-tick);
}
forward DoTest(); public DoTest() {
    new tick,i;
   
    print("- Starting Test(Do)");
       
    tick=GetTickCount();
    do{    
        printf("%d",i);        
        i++;
    }
    while(i < 5);    
    printf("(Do) Tempo: %d ms", GetTickCount()-tick);
}
forward StartTest(); public StartTest() {
    print("====Starting Test====");    
    ForTest();    
    WhileTest();    
    DoTest();    
    return 1;
}
Este codigo determinou qual era mais rapido, e eu obtive este resultado:

Код:
[15:53:40] ====Starting Test====
[15:53:40] - Starting Test(For)
[15:53:40] 0
[15:53:40] 1
[15:53:40] 2
[15:53:40] 3
[15:53:40] 4
[15:53:40] (FOR) Tempo: 6 ms
[15:53:40] - Starting Test(While)
[15:53:40] 0
[15:53:40] 1
[15:53:40] 2
[15:53:40] 3
[15:53:40] 4
[15:53:40] (While) Tempo: 4 ms
[15:53:40] - Starting Test(Do)
[15:53:40] 0
[15:53:40] 1
[15:53:40] 2
[15:53:40] 3
[15:53:40] 4
[15:53:40] (Do) Tempo: 4 ms
Normalmente o que vocкs devem fazer й um loop com a funзгo dentro do loop e usar o GetTickCount, ou seja, ele faria mais ou menos isto.

Comeзara a contar - fara o loop - fara a funзгo - exibe o resultado.

Perguntas Ferquentes

P: Para que servem estes Testes de velocidade?
R: Como disse, eles sгo testes lуgicos, sгo uteis para testar o seu script e tornar o mesmo mais rapido.

P: Esse teste que vocк fez serviu para que?
R: Serviu para determinar qual й o loop mais rapido, mas tambem pode ver este teste http://pastebin.com/6VarZyLk

Crйditos

BlueX~

Espero que gostem e tenham bons testes (:
Reply
#2

Gostei '
Reply
#3

god Job ^^
Reply
#4

Legal, agora vou saber fazer teste de velocidade da maneira correta!
Reply
#5

Quote:
Originally Posted by paulor
Посмотреть сообщение
Legal, agora vou saber fazer teste de velocidade da maneira correta!
o paulor tava precisando kkkk
Reply
#6

Nice!
Reply
#7

Sabia dessa nгo.
Agora sim, vou fazer teste em tudo que vк pela frente, kk.
Уtimo tutorial.
Reply
#8

https://sampforum.blast.hk/showthread.php?tid=208427
Reply
#9

Quote:
Originally Posted by Douglas_FusioN
Посмотреть сообщение
Gostei '
Valeu (:

Quote:
Originally Posted by BlackCoder
Посмотреть сообщение
god Job ^^
Thanks

Quote:
Originally Posted by paulor
Посмотреть сообщение
Legal, agora vou saber fazer teste de velocidade da maneira correta!
(:

Quote:
Originally Posted by BlackCoder
Посмотреть сообщение
o paulor tava precisando kkkk
Й

Quote:
Originally Posted by Juninho_Oakley
Посмотреть сообщение
Nice!
Valeu

Quote:
Originally Posted by Đeagle
Посмотреть сообщение
Sabia dessa nгo.
Agora sim, vou fazer teste em tudo que vк pela frente, kk.
Уtimo tutorial.
Thanks

Quote:
Originally Posted by DarkScripter
Посмотреть сообщение
kkkkkkkkkkk, vai me falar, Ah BlueX Vocк copiou o DraKiNs, filho, DraKiNs й meu amigo, ele jб nem liga mais para o samp, alias eu nem sabia que tinha um negocio feito por ele, o que eu fiz й trabalhoso, eu sou iPs ele й iPs, acha que eu ia copiar ele? Poupe-me.
Reply
#10

Gostei
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)