08.09.2010, 16:03
(
Последний раз редактировалось Lenny the Cup; 09.09.2010 в 17:53.
)
edit: Didn't see your post ****** 
I ran a new test to see how big the difference was between the two in three different situations:
1: Just a number (strtok(strval) vs "d")
2: A number and a name (strtok(strval) + strtok vs "du")
3: A number, a user AND the string (strtok(strval) + strtok + strrest vs "dus[24]")
Here is the script, same string as before:
And here are the results:
NOTE: INVALID TEST, SEE LATER TESTS

I ran a new test to see how big the difference was between the two in three different situations:
1: Just a number (strtok(strval) vs "d")
2: A number and a name (strtok(strval) + strtok vs "du")
3: A number, a user AND the string (strtok(strval) + strtok + strrest vs "dus[24]")
Here is the script, same string as before:
pawn Код:
main()
{
new TickStart,
idx,
szPlayer[MAX_PLAYER_NAME],
iCashAmount,
szEmote[80];
////////////////////////////////////////////////////////////////////////////
TickStart = GetTickCount();
for(new i; i < 100000; i++)
{
iCashAmount = strval(strtok(TESTSTRING, idx));
}
printf("RESULT 1 strtok & strrest: %d ticks.", GetTickCount() - TickStart);
TickStart = GetTickCount();
for(new i; i < 100000; i++)
{
sscanf(TESTSTRING, "d", iCashAmount);
}
printf("RESULT 1 sscanf: %d ticks.", GetTickCount() - TickStart);
////////////////////////////////////////////////////////////////////////////
TickStart = GetTickCount();
for(new i; i < 100000; i++)
{
iCashAmount = strval(strtok(TESTSTRING, idx));
format(szPlayer, MAX_PLAYER_NAME, strtok(TESTSTRING, idx));
}
printf("RESULT 2 strtok & strrest: %d ticks.", GetTickCount() - TickStart);
TickStart = GetTickCount();
for(new i; i < 10000; i++)
{
sscanf(TESTSTRING, "du", iCashAmount, szPlayer);
}
printf("RESULT 2 sscanf: %d ticks.", GetTickCount() - TickStart);
////////////////////////////////////////////////////////////////////////////
TickStart = GetTickCount();
for(new i; i < 100000; i++)
{
iCashAmount = strval(strtok(TESTSTRING, idx));
format(szPlayer, MAX_PLAYER_NAME, strtok(TESTSTRING, idx));
format(szEmote, 80, strrest(TESTSTRING, idx));
}
printf("RESULT 3 strtok & strrest: %d ticks.", GetTickCount() - TickStart);
TickStart = GetTickCount();
for(new i; i < 100000; i++)
{
sscanf(TESTSTRING, "dus[80]", iCashAmount, szPlayer, szEmote);
}
printf("RESULT 3 sscanf: %d ticks.", GetTickCount() - TickStart);
}
Код:
[18:03:41] RESULT 1 strtok & strrest: 68 ticks. [18:03:41] RESULT 1 sscanf: 47 ticks. [18:03:41] RESULT 2 strtok & strrest: 141 ticks. [18:03:41] RESULT 2 sscanf: 28 ticks. [18:03:41] RESULT 3 strtok & strrest: 382 ticks. [18:03:42] RESULT 3 sscanf: 417 ticks.