if(a && b)
if(a) if(b)
I beleive the first statement, just because surelly it would be quicker for the computer to process if(a && b) instead of two different if statements?
+rep if I helped. |
#include a_samp
#define START_BENCH(%0); {new __a=%0,__b=0,__c,__d=GetTickCount(),__e=1;do{}\
while(__d==GetTickCount());__c=GetTickCount();__d= __c;while(__c-__d<__a||\
__e){if(__e){if(__c-__d>=__a){__e=0;__c=GetTickCount();do{}while(__c==\
GetTickCount());__c=GetTickCount();__d=__c;__b=0;} }{
#define FINISH_BENCH(%0); }__b++;__c=GetTickCount();}printf(" Bench for "\
%0": executes, by average, %.2f times/ms.",floatdiv(__b,__a));}
main()
{
new f = 0;
new t = 1;
START_BENCH(1000);
if(t && f) {}
if(f && t) {}
FINISH_BENCH("2");
START_BENCH(1000);
if(t) if(f) {}
if(f) if(t) {}
FINISH_BENCH("1");
}
/*
[16:11:55] Bench for 2: executes, by average, 3445.79 times/ms.
[16:11:57] Bench for 1: executes, by average, 4688.54 times/ms.
*/
[16:14:40] Bench for 2: executes, by average, 3473.32 times/ms. [16:14:42] Bench for 1: executes, by average, 3804.91 times/ms.
#include a_samp
public OnFilterScriptInit()
{
new f = 0;
new t = 1;
new locate = GetTickCount();
for(new i; i != 1000000; ++i)
{
if(t && f) {}
if(f && t) {}
}
printf("Reply of metod whidth &&: %d", GetTickCount() - locate);
locate = GetTickCount();
for(new i; i != 1000000; ++i)
{
if(t) if(f) {}
if(f) if(t) {}
}
printf("Reply of metod whidth IF: %i", GetTickCount() - locate);
}
[16:19:22] Reply of metod whidth &&: 92 [16:19:22] Reply of metod whidth IF: 94
proc ; main ; line 2 ; line 3 break ; c ;$lcl a fffffffc push.c 0 ;$exp ;$lcl b fffffff8 push.c 0 ;$exp ; line 4 break ; 20 load.s.pri fffffffc jzer 1 load.s.pri fffffff8 jzer 1 const.pri 1 jump 2 l.1 zero.pri l.2 jzer 0 ;$exp l.0 ; 60 stack 8 zero.pri retn
proc ; main ; line 2 ; line 3 break ; c ;$lcl a fffffffc push.c 0 ;$exp ;$lcl b fffffff8 push.c 0 ;$exp ; line 4 break ; 20 load.s.pri fffffffc jzer 0 ;$exp ; line 6 break ; 34 load.s.pri fffffff8 jzer 1 ;$exp l.1 ; 48 l.0 ; 48 stack 8 zero.pri retn
LOAD.S.pri fffffff8
JZER 1
LOAD.S.pri fffffffc
JZER 1
CONST.pri 1
JUMP 2
l.1
ZERO.pri
l.2
JZER 0
; $exp
l.0 ; a8
LOAD.S.pri fffffff8
JZER 3
; $exp
LOAD.S.pri fffffffc
JZER 4
; $exp
l.4 ; c8
l.3 ; c8