why allocation of large amount of small objects so slow (x10) in D?

Leandro Lucarella llucax at gmail.com
Thu May 21 17:50:02 PDT 2009


nobody, el 22 de mayo a las 00:08 me escribiste:
> $ g++     alloc.cpp   -o alloc
> $ time ./alloc
> real    0m1.946s
> user    0m1.688s
> sys     0m0.256s
> 
> $ dmd -O -release allocd.d
> $ time ./allocd
> real    0m22.734s
> user    0m22.353s
> sys     0m0.360s
> 
> $ cat alloc.cpp
> #include <vector>
> 
> typedef std::vector<int> intvec;
> typedef intvec* intvecp;
> 
> int main() {
>   int i, n = 20000000;
>   intvecp* iva;
>   iva = new intvecp[n];
>   for (i = n; i-- > 0; ) {
>     iva[i] = new intvec();
>   }
> 
>   return 0;
> }
> 
> $ cat allocd.d
> int main() {
>   int i, n = 20000000;
>   Object[] oa;
>   oa = new Object[n];
>   for (i = n; i-- > 0; ) {
>     oa[i] = new Object();
>   }
> 
>   return 0;
> }

You mean why GCC C++ compiler is faster than DM D compiler. You are
comparing 2 different compiler implementations for 2 different languages.
It's really hard to get any conclusion from that.

It would be much more meaningfull if you compare g++ vs gdc or dmd vs dmc
or ldc vs llvm-g++ (they at least use the same backend).

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Oiganmen ñatos de corazón, es más posible que un potus florezca en
primavera a que un ángel pase con una remera.
	-- Peperino Pómoro



More information about the Digitalmars-d mailing list