size_t for length on x64 will make app slower than on x86?
FrankLike via Digitalmars-d
digitalmars-d at puremagic.com
Mon Nov 17 07:28:50 PST 2014
I test it:
module aasize_t;
import std.stdio;
import std.datetime;
import std.conv;
import std.string;
size_t[string] aa;
void gettime()
{
for(size_t i=0;i<3000000;i++)
{
aa[to!string(i)] = i;
}
}
void main()
{ writeln("size_t.max",size_t.max);
gettime();
void getlen(){auto alne = aa.length;}
auto r = benchmark!(getlen)(10000);
auto f0Result = to!Duration(r[0]); // time f0 took to run 10,000
times
writeln("\n size_t time is :",f0Result);
StopWatch sw;
sw.start();
gettime();
sw.stop();
writeln("\n size_t time is sw:",sw.peek.msecs," msecs");
}
----------and anoter is uint[string] aa
dmd -m64 aauint.d
dmd -m64 aasize_t.d
dmd aaint.d -ofaauint32.exe
dmd aasize_t.d -ofaasize_t32.exe
@del *.obj
aaint
aasize_t
aaint32
aasize_t32
@pause
Last Result:
They take the almost same time,and usage memory. but uint(or int)
is more practical for length to use.
More information about the Digitalmars-d
mailing list