[DUG] Curious re efficiency of using in [set of integer]
Tech Benner
tech at benner.nz
Tue Aug 16 09:57:45 NZST 2022
HI Rohit,
My concern about optimisation was to do with the test example only,
using the same parameters many times to show up a measurable time
difference.
Cheers
Gary
On 16/08/2022 9:54 am, Rohit Gupta wrote:
>
> Ross, that was my expectation, that the SET would be slightly faster.
>
> The *set *should *fetch *the data, *shift *it and *and *it.
>
> Where as the *or *should *fetch *the data and execute two *compare
> *and *jump *type instructions.
>
> In this case, I doubt if the optimisation would make much difference.
> Optimisation make a significant difference to loops and where a
> variable/constant is used again and again.
>
> Regards
>
> *Rohit Gupta*
> B.E. Elec., M.E., Mem IEEE, Member IET
>
> On 15/08/2022 22:51, Ross Levis wrote:
>>
>> I did the test but had to use a loop 40000000 times to get some
>> separation. The in set statement was actually faster than doing 2
>> “or” statements. Around 76 to 65 ticks. Basically identical and both
>> too fast to be concerned with.
>>
>> *From:*delphi-bounces at listserver.123.net.nz
>> [mailto:delphi-bounces at listserver.123.net.nz] *On Behalf Of *Ross Levis
>> *Sent:* Monday, 15 August 2022 6:11 pm
>> *To:* 'NZ Borland Developers Group - Delphi List'
>> *Cc:* delphi at delphi.org.nz
>> *Subject:* Re: [DUG] Curious re efficiency of using in [set of integer]
>>
>> I should do that.
>>
>> It may matter if it’s converting to something expensive code in ASM,
>> and this code is being executed a few thousand times.
>>
>> *From:*delphi-bounces at listserver.123.net.nz
>> [mailto:delphi-bounces at listserver.123.net.nz] *On Behalf Of *Rohit Gupta
>> *Sent:* Monday, 15 August 2022 6:01 pm
>> *To:* NZ Borland Developers Group - Delphi List
>> *Cc:* delphi at delphi.org.nz
>> *Subject:* Re: [DUG] Curious re efficiency of using in [set of integer]
>>
>> Just put it in a loop of 10k and time it.
>>
>> But honestly, does it really matter?
>>
>> Regards
>> Rohit
>>
>> 15/08/2022 17:34:14 Ross Levis <ross at stationplaylist.com>:
>>
>> Var Total: Integer;
>>
>> If I want to test 2 or 3 values of an integer, I often use
>>
>> *if Total in [4,6] then ...*
>>
>> But is that more or less efficient for the CPU/ASM coding than
>>
>> *if (Total = 4) or (Total = 6) then ...*
>>
>> I’m not sure how to find out myself.
>>
>>
>> _______________________________________________
>> NZ Borland Developers Group - Delphi mailing list
>> Post:delphi at listserver.123.net.nz
>> Admin:http://delphi.org.nz/mailman/listinfo/delphi
>> Unsubscribe: send an email todelphi-request at listserver.123.net.nz with Subject: unsubscribe
>
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post:delphi at listserver.123.net.nz
> Admin:http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email todelphi-request at listserver.123.net.nz with Subject: unsubscribe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20220816/7bc2c205/attachment-0001.html
More information about the Delphi
mailing list