[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Looping through an array with FOR EACH


Il 16/01/26 16:49, Gianluigi ha scritto:
Il 16/01/26 15:55, Brian G ha scritto:
Out of interest to see just how bad time wise using for each was, I put together a little test and was quite surprised by the result:

Ranking of each type of iteration by time

1       For each hybrid Time= 0.758384959, Total=9000003 0.758384959073737
2       Index only      Time= 0.837044355, total=9000003 0.83704435499385
3       for each only   Time= 1.282145344, Total=9000003 1.28214534395374

The short program is below.
It look like a combination of both types together depending on the array structure is best!



On my over 5-year-old PC (which I built myself 🤪 ), these are the results of your test:

Ranking of each type by time
1       For each hybrid Time= 0,461964985, Total=9000003 0,461964984999213
2       Index only      Time= 0,467335708, total=9000003 0,467335707999155
3       for each only   Time= 0,811512829, Total=9000003 0,811512829001003


Hi Brian,

I've done various tests, even added a 0(*), and I'd say the hybrid is always faster.

Regards
Gianluigi

(*) Ranking of each type by time
1 For each hybrid Time= 4,945550591, Total=90000003 4,9455505909973 2 Index only Time= 5,238530005, total=90000003 5,23853000500094 3 for each only Time= 8,906546153, Total=90000003 8,90654615300082


References:
Looping through an array with FOR EACHGianluigi <gradobag@xxxxxxxxxxx>
Re: Looping through an array with FOR EACHBB <adamnt42@xxxxxxxxx>
Re: Looping through an array with FOR EACHGianluigi <gradobag@xxxxxxxxxxx>
Re: Looping through an array with FOR EACHBrian G <brian@xxxxxxxxxxxxxxxx>
Re: Looping through an array with FOR EACHGianluigi <gradobag@xxxxxxxxxxx>
Re: Looping through an array with FOR EACHBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: Looping through an array with FOR EACHGianluigi <gradobag@xxxxxxxxxxx>
Re: Looping through an array with FOR EACHBrian G <brian@xxxxxxxxxxxxxxxx>
Re: Looping through an array with FOR EACHGianluigi <gradobag@xxxxxxxxxxx>
Re: Looping through an array with FOR EACHBruce Steers <bsteers4@xxxxxxxxx>
Re: Looping through an array with FOR EACHBrian G <brian@xxxxxxxxxxxxxxxx>
Re: Looping through an array with FOR EACHGianluigi <gradobag@xxxxxxxxxxx>