size_t for length on x64 will make app slower than on x86?

Matthias Bentrup via Digitalmars-d digitalmars-d at puremagic.com
Mon Nov 17 03:59:24 PST 2014


On Sunday, 16 November 2014 at 16:02:20 UTC, FrankLike wrote:
>
>> It means where you have uint x = arr.length you should have 
>> had size_t x = arr.length from the very beginning.
>
> I test it :
>
> module aatest;
> import std.stdio;
> import std.datetime;
> import std.conv;
> size_t[string] aa;
>
> void ada()
> {
> 	for(size_t i=0;i<1000000;i++)
> 	{
> 		aa[to!string(i)] =i;
> 	}
> }
> void main()
> {
> 	StopWatch sw;
> 	sw.start();
> 	ada();
> 	sw.stop();
> 	writeln("\n time is :" , sw.peek().msecs/1000.0," secs");
>
> }
> dmd -m64 aatest.d ,and dmd   aatest.d -ofaa32.exe
> Result:
> m64 :0.553 secs;
> m32:0.5 secs;
>
> Thank you all.

I ran your test program through a profiler, and it spends >40% of 
the time in garbage collection. So I think the slightly longer 
run time is due to the 64 bit GC being a bit slower than the 32 
bit GC.


More information about the Digitalmars-d mailing list