11.10.2016, 18:42
I ran few tests and if the length is long, these two made a difference:
This is the fastest:
and second comes:
http://pastebin.com/raw/AdJuRncr
Results:
EDIT: I removed the part I was setting the text in the loops and did few more. The result for longer strings are the same but for 1 or 2 characters only, this becomes the fastest:
This is the fastest:
pawn Код:
for(j = strlen(string); --j != -1;)
pawn Код:
for(j = strlen(string); j != 0; j --)
Results:
pawn Код:
Bench for 1st: executes, by average, 168.35 times/ms.
Bench for 2nd: executes, by average, 156.76 times/ms.
Bench for 3rd: executes, by average, 173.58 times/ms.
Bench for 4th: executes, by average, 168.80 times/ms.
Bench for 5th: executes, by average, 171.69 times/ms.
Bench for 6th: executes, by average, 149.65 times/ms.
Bench for 7th: executes, by average, 174.24 times/ms.
Bench for 8th: executes, by average, 223.66 times/ms.
Bench for 9th: executes, by average, 174.86 times/ms.
Bench for 10th: executes, by average, 174.98 times/ms.
Bench for 11th: executes, by average, 217.67 times/ms.
pawn Код:
for(j = 0; string[j]; j ++)