The nail in the coffin of C++ or why don't GO there...

Dmitry Olshansky via Digitalmars-d digitalmars-d at puremagic.com
Thu Mar 30 16:46:11 PDT 2017


On 3/30/17 1:03 PM, Ervin Bosenbacher wrote:
> On Thursday, 30 March 2017 at 10:28:01 UTC, dennis luehring wrote:
>> Am 30.03.2017 um 08:58 schrieb Ervin Bosenbacher:
>>> That is the same, that came as a shock to me.
>>
>> most compilers (for many languages) can optimize your super-trivial
>> example down to nothing - for at least the last 10 years or more
>>
>> so whats the point? you're talkin about "performance is critical for me"
>> but missing even minor knowledge about todays compiler powers?
>>
>> for a benchmark you need:
>> -loops, running millions of times, preventing IO and do now fall into
>> the completely-optimized-to-nothing-trap etc.
>
> Tried again, threw in summing up a number 10 million times and repeat
> the arrays 10 million times, I have used arrays on the stack for the D
> version. And when I am talking about performance I am curious about CPU
> bound stuff.
>
> The D version:
>
> import std.stdio;
>
> void main()
> {
>     long sum = 0;
>     foreach (long i; 0 .. 10000000) {
>         int[12] months = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,
> 31 ];
>         int[3] first = months[0 .. 3];
>         int[3] second = months[3 .. 6];
>         int[3] third = months[6 .. 9];
>         int[3] fourth = months[9 .. 12];
>

Most of this code may be easily eliminated by dead-code removal. So you 
probably just measure the summing loop alone. To be certain look at 
disassembly.

---
Dmitry Olshansky




More information about the Digitalmars-d mailing list