"Iain Buclaw" <ibuc...@ubuntu.com> wrote in message
news:ie6ahr$1co...@digitalmars.com...
== Quote from Craig Black (craigbla...@cox.net)'s article
> Testing your C++ program (altered getCycle() for GCC)
>
> Times I get:
> -------
> Sorting with Array: 46869.159840
> Sorting with pointers: 38688.937320
> 17.453316 percent faster
>
> Sorting with Array: 46631.903760
> Sorting with pointers: 38520.609360
> 17.394302 percent faster
>
> Sorting with Array: 46674.330720
> Sorting with pointers: 38545.202520
> 17.416700 percent faster
> -------
>
>
> On a , I thought I might try an older version of GCC for the D program.
> Really surprisingly, I got:
>
> -------
> Sorting with Array.opIndex: 43075.059840
> Sorting with pointers: 40019.701920
> 7.093102 percent faster
>
> Sorting with Array.opIndex: 42940.085640
> Sorting with pointers: 39594.089040
> 7.792245 percent faster
>
> Sorting with Array.opIndex: 44389.127280
> Sorting with pointers: 41159.016960
> 7.276805 percent faster
> -------
>
> This will need some thinking through as to just what happened between
> GDC-4.3 -> GDC-4.4 :~)
>
> Regards
Curious benches there. Seems GCC isn't inlining (or other optimization)
as
well as Visual C++ here. I'm getting a neglible ~2% difference.
-Craig
OK, found and fixed the problem with GDC-4.4. My results are now:
g++-4.4 -O3 -march=native -ftree-vectorize
-------
Sorting with Array: 45861.599640
Sorting with pointers: 38417.632680
16.231372 percent faster
Sorting with Array: 46421.979120
Sorting with pointers: 38474.709840
17.119626 percent faster
Sorting with Array: 48622.885200
Sorting with pointers: 39593.385600
18.570473 percent faster
-------
gdc-4.4 -frelease -O3 -march=native -ftree-vectorize
-------
Sorting with Array.opIndex: 41454.052200
Sorting with pointers: 38331.517560
7.532520 percent faster
Sorting with Array.opIndex: 41109.852720
Sorting with pointers: 37836.883320
7.961521 percent faster
Sorting with Array.opIndex: 40587.349320
Sorting with pointers: 37390.488120
7.876497 percent faster
-------
dmd-2.050 -release -O -inline
-------
Sorting with Array.opIndex: 53561.598720
Sorting with pointers: 48348.626760
9.732667 percent faster
Sorting with Array.opIndex: 55861.658280
Sorting with pointers: 49909.880760
10.654495 percent faster
Sorting with Array.opIndex: 56887.660800
Sorting with pointers: 51470.453400
9.522640 percent faster
-------
I noticed that with dmd -inline needs to be explicitly set. Otherwise
there appears to be nothing to suggest a wild difference
between using opIndex and pointers. :~)
Regards
Thanks for your help and interest. Basically you are saying I should use
GDC instead? I've heard rumors that GDC is not as stable. Can you comment
on this? I am still getting different results than you with dmd, but maybe
that's because we have different machines?
My results on a core i7 1.86 GHz notebook:
dmd-2.050 -O -release -inline
Sorting with Array.opIndex: 19160.2
Sorting with pointers: 15006.4
21.6791 percent faster
Sorting with Array.opIndex: 20200.8
Sorting with pointers: 15699.1
22.2887 percent faster
Sorting with Array.opIndex: 19563.3
Sorting with pointers: 15418.4
21.1872 percent faster
-Craig