[Benchmark] strpack vs format -
Lenny the Cup - 05.04.2011
I made a quick benchmark script to see which was faster, just sharing them here for the record:
pawn Код:
#include <a_samp>
main()
{
new
StartTick,
StopTick,
string[16],
string2[16];
format(string2, 17, "I like big butts");
StartTick = GetTickCount();
for(new i; i < 1000000; i++)
{
format(string, 17, string2);
}
StopTick = GetTickCount();
printf("format: %d ms", StopTick-StartTick);
for(new i; i < 1000000; i++)
{
strpack(string, string2, 17);
}
StopTick = GetTickCount();
printf("strpack: %d ms", StopTick-StartTick);
return 1;
}
Result:
[21:40:19] format: 351 ms
[21:40:19] strpack: 524 ms
Conclusion: format is faster.
Re: [Benchmark] strpack vs format -
WackoX - 05.04.2011
k
Код:
The message you have entered is too short. Please lengthen your message to at least 4 characters.
Re: [Benchmark] strpack vs format -
Placebo - 05.04.2011
Cool, that's nice to know
Re: [Benchmark] strpack vs format -
randomkid88 - 05.04.2011
Shouldn't you re-fetch StartTick after the first code executes? If not, aren't you taking the time it takes for format AND strpack to execute (aka when the server started), which is not what you want. You want the time each section of code took to execute. I did that and got this:
Код:
format: 319 ms
strpack: 137 ms
pawn Код:
#include <a_samp>
main()
{
new
StartTick,
StopTick,
string[16],
string2[16];
format(string2, 17, "I like big butts");
StartTick = GetTickCount();
for(new i; i < 1000000; i++)
{
format(string, 17, string2);
}
StopTick = GetTickCount();
printf("format: %d ms", StopTick-StartTick);
StartTick = GetTickCount();
for(new i; i < 1000000; i++)
{
strpack(string, string2, 17);
}
StopTick = GetTickCount();
printf("strpack: %d ms", StopTick-StartTick);
return 1;
}
Re: [Benchmark] strpack vs format -
Lenny the Cup - 05.04.2011
Haha Jesus, sorry you're right
I was a bit tired, guess that's why I missed that!
AW: [Benchmark] strpack vs format -
Nero_3D - 05.04.2011
so strpack was like expected faster but what has format to do with strpack or vica versa ?
Re: AW: [Benchmark] strpack vs format -
randomkid88 - 05.04.2011
Quote:
Originally Posted by Nero_3D
so strpack was like expected faster but what has format to do with strpack or vica versa ?
|
My question too. You can't effectively use strpack to put arguments into a string. You would have to use strins which would be difficult, time-consuming, and inefficient.
Re: [Benchmark] strpack vs format -
Lenny the Cup - 05.04.2011
I often see people use format to copy a string to another, so I was curious to see which way was actually more effective. Like I said I'm only posting it here for the record, so it's somewhere to be found
AW: [Benchmark] strpack vs format -
Nero_3D - 05.04.2011
Than you missed to read that topic =>
Code optimisation