AA performance again

davidl davidl at 126.com
Fri Jun 13 00:14:30 PDT 2008


在 Tue, 10 Jun 2008 06:02:00 +0800,bearophile <bearophileHUGS at lycos.com>  
写道:

> Walter Bright:
>
>> Python uses 32 bit integers, so the equivalent D AA would be:
>> 	size_t[int] aa;
>> D longs are 64 bits.
>
> As usual you are right and I am wrong :-)
> My purpose is to have a good language to use, and you can see I like D  
> :-) (I conflate AAs into the language because they are built in).
>
> Python 2.5 uses 32 signed numbers by default, but they are objects, and  
> they are converted to multiprecision numbers whenever necessary:
>
>>>> a = 2147483647
>>>> type(a)
> <type 'int'>
>>>> b = a + 1
>>>> b
> 2147483648L
>>>> type(b)
> <type 'long'>
>
> In Python 3 all numbers will be longs (at the moment they are about  
> 25-30% slower, I think, but Python 3 is in beta still).
>
> ------------------
>
> I have tested with uints then (no GC), the new D code:
>
> import std.conv: toUint;
> import std.gc: disable, enable;
> void main(string[] args) {
>     uint n = toUint(args[1]);
>     size_t[uint] aa;
>     disable;
>     for (uint i; i < n; ++i)
>         aa[i] = 0;
>     enable;
> }
>
> The timings seem the same:
> 1_000_000     0.27 s
> 2_000_000     0.59 s
> 5_000_000     2.14 s
> 10_000_000    8.87 s
> 20_000_000   29.9  s
>
> If someone can confirm such timings...
>
> Bye and thank you,
> bearophile

I think the most important issue is D's AA(Phobos) is not balanaced.
Tango should perform worse in this case.
While this case is almost a useless showcase of testing. AA keys are  
seldom well organized in this way.
And this way is actually the worst case for D's AA.

You should firstly generate some random strings to a file, and read this  
file to test both pythons' and Ds' AA.

It's ridiculous that python can be any bit faster than D.
The crucial bottle neck I can see, is the bucket tree not balanced in D.  
Once this is fixed in phobos, you should get the best performance AA,  
other AA won't be exponetial times faster than this, if there's , your  
fault.





-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/



More information about the Digitalmars-d mailing list