[Issue 5100] New: -O Degrades performance of loop statements

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 22 05:57:14 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=5100

           Summary: -O Degrades performance of loop statements
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: ibuclaw at ubuntu.com


--- Comment #0 from Iain Buclaw <ibuclaw at ubuntu.com> 2010-10-22 05:56:32 PDT ---
Two example cases:

loop1.d
---------
void main()
{
    for (int i = 0; i < int.max; i++)
    {
    }
}


loop2.d
---------
void main()
{
    int i = 0;
    while(i < int.max)
    {
        i++;
    }
}


$ dmd loop1.d
$ time ./loop1 
real    0m2.914s
user    0m2.884s
sys    0m0.012s

$ ./dmd loop1.d -O
$ time ./loop1 
real    0m5.695s
user    0m5.684s
sys    0m0.004s

$ ./dmd loop2.d 
$ time ./loop2
real    0m2.912s
user    0m2.892s
sys    0m0.004s

$ ./dmd loop2.d -O
$ time ./loop2
real    0m5.703s
user    0m5.688s
sys    0m0.004s


The speed of execution slows by almost double when optimisations are turned on.
Something isn't right here...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list