08.09.2010, 16:26
(
Последний раз редактировалось Lenny the Cup; 09.09.2010 в 17:53.
)
I ran a new test:
So apparently sscanf reads strings slightly slower than strrest (The version ****** presented).
Edit:
But on the other hand, integers are quicker:
NOTE: INVALID TEST, SEE LATER TESTS
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.
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.