Fastest String Loop
#1

I posted this thread as most people create their loops that go through strings as follows:

for(new j = 0, k = strlen(string); j < k; j ++)

Which ended up in 3rd.

----------------------------------------------------

***** 1,000,000 ITERATIONS *****

// ** Lowest: 2,666 ms | Highest: 2,724 ms

Код:
new j = (strlen(string) - 1);
while(j != -1)
{
	j --;
}
// ** Lowest: 2,648 ms | Highest: 2,700 ms

Код:
new j, k = strlen(string);
while(j != k)
{
	j ++;
}
// ** Lowest: 2,619 ms | Highest: 2,686 ms

Код:
new j = -1;
while(string[++ j])
// ** Lowest: 2,536 ms | Highest: 2,599 ms

Код:
new j = strlen(string);
do
{
	j --;
}
while(j != 0);
// ** Lowest: 1,428 ms | Highest: 1,450 ms

Код:
for(j = 0; string[j]; j ++)
// ** Lowest: 1,422 ms | Highest: 1,440 ms

Код:
for(new j = 0; string[j] != EOS; j ++)
// ** Lowest: 1,320 ms | Highest: 1,351 ms

Код:
for(new j = (strlen(string) - 1); j > -1; j --)
// ** Lowest: 1,314 ms | Highest: 1,349 ms

Код:
for(new j = strlen(string); --j != -1;)
// ** Lowest: 1,309 ms | Highest: 1,319 ms

Код:
for(new j = 0, k = strlen(string); j < k; j ++)
// ** Lowest: 1,299 ms | Highest: 1,324 ms

Код:
for(new j = 0, k = strlen(string); j != k; j ++)
// ** Lowest: 1,193 ms | Highest: 1,225 ms

Код:
for(new j = strlen(string); j != 0; j --)
{
	// printf("%d", j - 1);
}
Reply


Messages In This Thread
Fastest String Loop - by SickAttack - 11.10.2016, 03:03
Re: Fastest String Loop - by SyS - 11.10.2016, 03:48
Re: Fastest String Loop - by SickAttack - 11.10.2016, 04:57
Re: Fastest String Loop - by Gammix - 11.10.2016, 05:55
Re: Fastest String Loop - by Yashas - 11.10.2016, 07:09
Re: Fastest String Loop - by SyS - 11.10.2016, 07:54
Re: Fastest String Loop - by SickAttack - 11.10.2016, 14:56
Re: Fastest String Loop - by Luicy. - 11.10.2016, 15:16
Re: Fastest String Loop - by SyS - 11.10.2016, 15:18
Re: Fastest String Loop - by SickAttack - 11.10.2016, 15:27
Re: Fastest String Loop - by Jayse - 11.10.2016, 16:22
Re: Fastest String Loop - by Stinged - 11.10.2016, 18:18
Re: Fastest String Loop - by Konstantinos - 11.10.2016, 18:42

Forum Jump:


Users browsing this thread: 1 Guest(s)