Let Go, Standard Library From Community
Derek Parnell
derek at psych.ward
Fri Apr 20 15:27:57 PDT 2007
On Fri, 20 Apr 2007 10:27:14 -0700, Stephen Waits wrote:
> Daniel Keep wrote:
>>
>> To be honest, I wouldn't know the most efficient way to return or pass
>> out a vector because I've never had any kind of grounding in the effects
>> of the various ways of doing it. For instance: at what point does
>> passing by reference become faster than by value?
>
> 10 second lesson on optimization:
>
> * Memory access is slow. Both reading and writing. It's generally been
> that way for a long time, and appears to be staying that way.
'Slow' compared to Register access rather than Disk access <G>
In other words, try to use the data that is in registers rather than get it
(again) from RAM, and try to use registers as temporary/intermediate areas.
> * Optimize what is slowest.
>
> * Know what's slowest by profiling.
A concentrate on slow functions that are used frequently rather those that
are rarely used. I've seen people spend way to much time on shaving off
milliseconds from a program's initialization section rather than deal with
other areas that are run thousands of times each time the application is
executed.
> * The largest gains generally come from larger algorithmic changes.
YES! Time spent working on getting the best algorithm is always going to
pay dividends. Improving the efficiency of a bubble-sort for
million-element array is probably a waste of time.
--
Derek Parnell
Melbourne, Australia
"Justice for David Hicks!"
skype: derek.j.parnell
More information about the Digitalmars-d
mailing list