Lisp like lists and a problem with TANGO fromStringz

kov_serg kov_serg at freemail.ru
Mon Mar 3 08:41:03 PST 2008


bearophile Wrote:

...
> 
> OUTPUT TIMINGS:
> 
> DMD 1.026, N = 12_000_000:
>   append:            3.3 s
>   reserve + append:  3.3 s
>   allocate + assign: 1.0 s
> 
> C++ MinGW 4.2.1, N = 12_000_000, best of 3:
>   append:            1.4 s
>   reserve + append:  0.5 s
>   allocate + assign: 1.0 s
> 
> C++ compiled with -O3 -s
> DMD compiled with -O -release -inline
> Win on Pentium3 CPU.
> 
> Notes:
> - All timings are best of 3, rounded to 2 significant digits.
> - I don't understand how in C++ the append() can twice faster than the assign.
...
It's simple.
1st do not use clock function -- it measure processor time for current thread. Simply use funtion that measure the time passed.
2nd reason is CPU cache behaviour. Turn it off and compare again.

http://en.wikipedia.org/wiki/CPU_cache
http://leitl.org/docs/comp/AMD_block_prefetch_paper.pdf
...




More information about the Digitalmars-d mailing list