AA performance again
Lars Ivar Igesund
larsivar at igesund.net
Fri Jun 13 00:25:53 PDT 2008
davidl wrote:
> 在 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.
Curious about your argumentation here (or test results showing that this is
true), if you intended to write what you did.
--
Lars Ivar Igesund
blog at http://larsivi.net
DSource, #d.tango & #D: larsivi
Dancing the Tango
More information about the Digitalmars-d
mailing list