02.06.2012, 02:35
6 loops
all make the same thing
all make 100milion iterations
but they spend VERY different times
result:
now I ask:
why?
all make the same thing
all make 100milion iterations
but they spend VERY different times
PHP код:
new a = GetTickCount();
new n = 0;
a = GetTickCount();
while( n < 1000000000 )
if(n++ == 100000000)
break;
printf("tempo1 = %d",GetTickCount() - a);
n = 0;
a = GetTickCount();
while( n < 200000000 )
if(n++ == 100000000)
break;
printf("tempo2 = %d",GetTickCount() - a);
n = 0;
a = GetTickCount();
while( n < 100000001 )
if(n++ == 100000000)
break;
printf("tempo3 = %d",GetTickCount() - a);
n = 0;
a = GetTickCount();
while( 1 < 2 )
if(n++ == 100000000)
break;
printf("tempo4 = %d",GetTickCount() - a);
n = 0;
a = GetTickCount();
for(new t = 0; t < 100000000; t++)
if(n++ == 100000000)
break;
printf("tempo5 = %d",GetTickCount() - a);
n = 0;
a = GetTickCount();
for(new t = 0; t < 10000002; t++)
if(n++ == 100000000)
break;
printf("tempo6 = %d",GetTickCount() - a);
Quote:
|
[23:41:30] tempo1 = 3705 [23:41:33] tempo2 = 3745 [23:41:37] tempo3 = 3733 [23:41:39] tempo4 = 1625 [23:41:41] tempo5 = 2698 [23:41:42] tempo6 = 268 |
why?

