October 28, 2014
On Tuesday, 28 October 2014 at 11:48:37 UTC, MattCoder wrote:
> And in my benchmark test, the first version is 3x "slower" than the second one.

I forgot to say that I'm compiling with DMD without any compiler hints/optimizations.

Matheus.
October 28, 2014
On Monday, 27 October 2014 at 22:53:57 UTC, Nordlöw wrote:
>> Why bidirectional range only?
>
> popBack() only for
>

I mean: you should write a different version for non-bidirectional ranges too :)
October 28, 2014
On Tuesday, 28 October 2014 at 11:51:42 UTC, MattCoder wrote:
> I forgot to say that I'm compiling with DMD without any compiler hints/optimizations.

Try compiling with DMD flag

-release

and perhaps also

-release -noboundscheck

to get relevant results.

DMD is currently not that good at inlining range primitives.
October 28, 2014
On Tuesday, 28 October 2014 at 13:30:05 UTC, Nordlöw wrote:
> On Tuesday, 28 October 2014 at 11:51:42 UTC, MattCoder wrote:
>> I forgot to say that I'm compiling with DMD without any compiler hints/optimizations.
>
> Try compiling with DMD flag
>
> -release
>
> and perhaps also
>
> -release -noboundscheck
>
> to get relevant results.
>
> DMD is currently not that good at inlining range primitives.

Interesting!

With -release the second version still faster but only by 10%.

Now with: -release -noboundscheck they are equal and sometimes your version is slightly faster by ~3 milliseconds.

Matheus.
October 28, 2014
On Tuesday, 28 October 2014 at 14:09:50 UTC, MattCoder wrote:
> Now with: -release -noboundscheck they are equal and sometimes your version is slightly faster by ~3 milliseconds.

That is great to hear!

You should try profiling with ldc aswell.
October 28, 2014
On Tuesday, 28 October 2014 at 14:09:50 UTC, MattCoder wrote:
> On Tuesday, 28 October 2014 at 13:30:05 UTC, Nordlöw wrote:
>> On Tuesday, 28 October 2014 at 11:51:42 UTC, MattCoder wrote:
>>> I forgot to say that I'm compiling with DMD without any compiler hints/optimizations.
>>
>> Try compiling with DMD flag
>>
>> -release
>>
>> and perhaps also
>>
>> -release -noboundscheck
>>
>> to get relevant results.
>>
>> DMD is currently not that good at inlining range primitives.
>
> Interesting!
>
> With -release the second version still faster but only by 10%.
>
> Now with: -release -noboundscheck they are equal and sometimes your version is slightly faster by ~3 milliseconds.
>
> Matheus.

I'm very surprise. If they either equal or fast sometimes the compiler did great optizations or it's just a multicore processor that's helping or what else? the first version (from your post, the one using ranges) change in each iteration two pointers (in pop*() calls) and request r's length 3 times (in .empty calls) while the second doesn't, just run until an already know index (when enter in the loop) and access two index in each iteration. This without consider the amount of ifs.

I don't know, maybe I just thinking in the C-way as that code would run.
October 29, 2014
On Tuesday, 28 October 2014 at 16:07:38 UTC, MachineCode wrote:
> I'm very surprise. If they either equal or fast sometimes the compiler did great optizations or it's just a multicore processor that's helping or what else? the first version (from your post, the one using ranges) change in each iteration two pointers (in pop*() calls) and request r's length 3 times (in .empty calls) while the second doesn't, just run until an already know index (when enter in the loop) and access two index in each iteration. This without consider the amount of ifs.
>
> I don't know, maybe I just thinking in the C-way as that code would run.

Yes, I'm curious about this too. I will check the assembly output later (When I have free time) to understand what is happening and why popFront/Back are faster than a loop.

Matheus.
1 2
Next ›   Last »