Performance penalty for using ranges
bearophile
bearophileHUGS at lycos.com
Sun Aug 25 14:45:26 PDT 2013
Timon Gehr:
>> ... but again, that will be slow compared to the for loop or a
>> foreach
>> across an interval.
>
> Why would that be the case?
In the real world, where we live, there is a thing named
"abstraction penalty", it's something that asks you to pay
something when there is an interface between separated
subsystems. To avoid paying that penalty at run-time in your
programs you need a smarter compiler, that usually requires more
time to be developed, and usually requires more time to do its
work (this means slower compilations, see the LDC2 compiler
compared to DMD. LDC2 was able to remove most of the run-time
penalty, but when it compiles it's slower than DMD). So in the
real life we have to take compromises all the time.
Bye,
bearophile
More information about the Digitalmars-d
mailing list