size_t for length on x64 will make app slower than on x86?
Flamencofantasy via Digitalmars-d
digitalmars-d at puremagic.com
Sun Nov 16 08:20:10 PST 2014
That's correct. Moving 64 bit values on a 32 bit machine results
in at least 2 machine instructions.
However I noticed that calling Length on Array in C# is inlined
whereas LongLenth is a function call even in release mode.
var length = array.Length;
000007FE8E453AF2 mov rax,qword ptr [rsp+20h]
000007FE8E453AF7 mov rax,qword ptr [rax+8]
000007FE8E453AFB mov dword ptr [rsp+30h],eax
var longLength = array.LongLength;
000007FE8E453B56 mov rax,qword ptr [rsp+20h]
000007FE8E453B5B cmp byte ptr [rax],0
000007FE8E453B5E mov rcx,qword ptr [rsp+20h]
000007FE8E453B63 call 000007FEEE082AB4
000007FE8E453B68 mov qword ptr [rsp+68h],rax
000007FE8E453B6D mov rax,qword ptr [rsp+68h]
000007FE8E453B72 mov qword ptr [rsp+40h],rax
On Sunday, 16 November 2014 at 16:03:30 UTC, Xinok wrote:
> On Sunday, 16 November 2014 at 13:39:24 UTC, FrankLike wrote:
>> Many old projects need move from x86 to x64,but the 'length'
>> type is size_t,it will change on x64,so a lot of work must to
>> do.but I find some info which is help for d:
>> http://www.dotnetperls.com/array-length.
>> it means:
>> test length and longlength, and found 'test longlength' is
>> slower than 'test length'.
>>
>> 0.64 ns Length
>> 2.55 ns LongLength
>>
>> I love D.So I don't want my app on x64 slower than on x86.
>>
>> Hope change in 2.067.
>>
>> Thank you all.
>
> We're missing too many details regarding how he ran his
> benchmark. If he compiled and ran his code as 32-bit, that
> could explain the discrepancy.
More information about the Digitalmars-d
mailing list