Interesting Test
#1

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);
}
Result:
[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);
}
Reply


Messages In This Thread
Interesting Test - by dowster - 20.09.2011, 22:02
Re: Interesting Test - by skullmuncher1337 - 20.09.2011, 22:57
Re: Interesting Test - by Babul - 20.09.2011, 23:45
Re: Interesting Test - by dowster - 21.09.2011, 00:52
Re: Interesting Test - by dowster - 21.09.2011, 01:00
Re: Interesting Test - by GrimR - 21.09.2011, 06:12
Re: Interesting Test - by GrimR - 21.09.2011, 10:41

Forum Jump:


Users browsing this thread: 3 Guest(s)