20.09.2011, 22:02
(
Последний раз редактировалось dowster; 20.09.2011 в 22:03.
Причина: made the code a bit more readable
)
pawn Код:
#include <a_samp>
#define ITERATIONS 100000000
main()
{
new tc, tc1, tc2, tc3;
tc = GetTickCount();
for(new i = 0; i < ITERATIONS; i++) {
new var = 5;
var = (var / 5); }
tc1 = (GetTickCount() - tc);
tc = GetTickCount();
for(new i = 0; i < ITERATIONS; i++) {
new var = 5;
var = (5 * ((1)/(5))); }
tc2 = (GetTickCount() - tc);
tc = GetTickCount();
for(new i = 0; i < ITERATIONS; i++) {
new var = 5;
var = (5 * 0.2); }
tc3 = (GetTickCount() - tc);
printf(" Test 1: %i, Test 2: %i, Test 3: %i", tc1, tc2, tc3);
}
[15:42:49] Test 1: 11253, Test 2: 3135, Test 3: 18068
Why would this happen, is it just the way that the math portion of a computer CPU processes math?
P.S. If above is too hard to read:
pawn Код:
#include <a_samp>
#define ITERATIONS 100000000
main()
{
new tc, tc1, tc2, tc3;
tc = GetTickCount();
for(new i = 0; i < ITERATIONS; i++)
{
new var = 5;
var = (var / 5);
}
tc1 = (GetTickCount() - tc);
tc = GetTickCount();
for(new i = 0; i < ITERATIONS; i++)
{
new var = 5;
var = (5 * ((1)/(5)));
}
tc2 = (GetTickCount() - tc);
tc = GetTickCount();
for(new i = 0; i < ITERATIONS; i++)
{
new var = 5;
var = (5 * 0.2);
}
tc3 = (GetTickCount() - tc);
printf(" Test 1: %i, Test 2: %i, Test 3: %i", tc1, tc2, tc3);
}