tonteria aparte... duda.
#8

Vaya parece que ese es todavнa mas rбpido que el format + strcat, pero por poquito:











pawn Код:
// [ DEVELOPMENT GAMEMODE ]

// INCLUDES:

#include <a_samp>

// RULES:

#pragma dynamic 1000000

// DEFINES:

#define MAX_ITERATIONS 10000

// MAIN:

main()
{
    print("Development Mode: format_benchmark.amx");

    new string_1[10000], temp[128], tick_1[2];

    tick_1[0] = GetTickCount();

    for(new i = 0; i < MAX_ITERATIONS; i ++)
    {
        format(temp, sizeof(temp), "%d", i);
        strcat(string_1, temp);
    }

    tick_1[1] = GetTickCount();

    new string_2[10000], tick_2[2];

    tick_2[0] = GetTickCount();

    for(new i = 0; i < MAX_ITERATIONS; i ++)
    {
        format(string_2, sizeof(string_2), "%s%d", string_2, i);
    }

    tick_2[1] = GetTickCount();

    new string_3[10000], tick_3[2], lenght;

    tick_3[0] = GetTickCount();

    for(new i = 0; i < MAX_ITERATIONS; i ++)
    {
        format(string_3[lenght], 10000 - lenght, "%d", i);
        lenght = strlen(string_3);
    }

    tick_3[1] = GetTickCount();

    printf("format and strcat: %d", tick_1[1] - tick_1[0]);
    printf("format: %d", tick_2[1] - tick_2[0]);
    printf("format-lenght: %d", tick_3[1] - tick_3[0]);
}

// CALLBACKS:

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}
Reply


Messages In This Thread
tonteria aparte... duda. - by OTACON - 11.06.2015, 13:00
Re: tonteria aparte... duda. - by M1tux3r - 11.06.2015, 13:04
Respuesta: tonteria aparte... duda. - by adri1 - 11.06.2015, 14:02
Re: Respuesta: tonteria aparte... duda. - by SickAttack - 11.06.2015, 15:00
Re: Respuesta: tonteria aparte... duda. - by Daniel-92 - 11.06.2015, 17:01
Re: Respuesta: tonteria aparte... duda. - by SickAttack - 11.06.2015, 18:32
Respuesta: tonteria aparte... duda. - by bm0z - 11.06.2015, 18:43
Re: tonteria aparte... duda. - by SickAttack - 11.06.2015, 23:54

Forum Jump:


Users browsing this thread: 1 Guest(s)