sscanf vs strtok & strrest
#6

I ran a new test:

pawn Код:
stock Test2()
{
    new TickStart,
        String[80],
        idx;
    TickStart = GetTickCount();
    for(new i; i < 100000; i++)
    {
        format(String, 80, strrest(TESTSTRING, idx));
    }
    printf("RESULT strtok & strrest: %d ticks.", GetTickCount() - TickStart);
    TickStart = GetTickCount();
    for(new i; i < 100000; i++)
    {
        sscanf(TESTSTRING, "s[80]", String);
    }
    printf("RESULT sscanf: %d ticks.", GetTickCount() - TickStart);
}
Код:
[18:30:21] RESULT strtok & strrest: 120 ticks.
[18:30:21] RESULT sscanf: 134 ticks.
So apparently sscanf reads strings slightly slower than strrest (The version ****** presented).




Edit:
But on the other hand, integers are quicker:
pawn Код:
stock Test3()
{
    new TickStart,
        Integer,
        idx;
    TickStart = GetTickCount();
    for(new i; i < 1000000; i++)
    {
        Integer = strval(strtok(TESTSTRING, idx));
    }
    printf("RESULT strtok & strrest: %d ticks.", GetTickCount() - TickStart);
    TickStart = GetTickCount();
    for(new i; i < 1000000; i++)
    {
        sscanf(TESTSTRING, "i", Integer);
    }
    printf("RESULT sscanf: %d ticks.", GetTickCount() - TickStart);
}
Код:
[18:34:04] RESULT strtok & strrest: 663 ticks.
[18:34:04] RESULT sscanf: 467 ticks.
NOTE: INVALID TEST, SEE LATER TESTS
Reply


Messages In This Thread
sscanf vs strtok & strrest - by Lenny the Cup - 08.09.2010, 15:26
Re: sscanf vs strtok & strrest - by playbox12 - 08.09.2010, 15:30
Re: sscanf vs strtok & strrest - by Lenny the Cup - 08.09.2010, 15:33
Re: sscanf vs strtok & strrest - by playbox12 - 08.09.2010, 15:44
Re: sscanf vs strtok & strrest - by Lenny the Cup - 08.09.2010, 16:03
Re: sscanf vs strtok & strrest - by Lenny the Cup - 08.09.2010, 16:26
Re: sscanf vs strtok & strrest - by Simon - 08.09.2010, 23:56
Re: sscanf vs strtok & strrest - by nemesis- - 09.09.2010, 04:23
Re: sscanf vs strtok & strrest - by Lenny the Cup - 09.09.2010, 17:28
Re: sscanf vs strtok & strrest - by Lenny the Cup - 09.09.2010, 17:33

Forum Jump:


Users browsing this thread: 1 Guest(s)