[Mono-bugs] [Bug 655380] New: String switch statement runs 5x slower on iPhone if compared to simple list of if statements

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Nov 22 17:32:53 EST 2010


https://bugzilla.novell.com/show_bug.cgi?id=655380

https://bugzilla.novell.com/show_bug.cgi?id=655380#c0


           Summary: String switch statement runs 5x slower on iPhone if
                    compared to simple list of if statements
    Classification: Mono
           Product: Mono: Compilers
           Version: 2.4.x
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: C#
        AssignedTo: msafar at novell.com
        ReportedBy: mantas at unity3d.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-US)
AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7

Problem observed on iPhone, using custom build of mono 2.4.x.

Following string switch code (100x iterations take 0.70 ms on iPhone 4) runs 5x
slower on iPhone:
        switch(arg)
        {
        case "Start":
            counter += 1;
            break;
        case "Update":
            counter += 2;
            break;
        case "Special":
            counter *= 2;
            break;
        default:
            counter -= 1;
            break;
        }
if compared to following simple "if" statement code (100x iterations take 0.12
ms on iPhone 4):
        if( arg == "Start" )
            counter += 1;
        else if( arg == "Update" )
            counter += 2;
        else if( arg == "Special" )
            counter *= 2;
        else
            counter -= 1;

Attached zip contains:
source cs files. 
compiled / ildisassembled .dll files.
disassembled final ARM binary 

Reproducible: Always

Steps to Reproduce:
1. Add attached code samples to iPhone project
2. Loop switch / if statement test code with 100 iterations
3. Compare execution times of these tests
Actual Results:  
Switch test takes 0.70 ms on iPhone 4
If test takes 0.12 ms on iPhone 4

Expected Results:  
Switch test takes about the same amount of time as if test

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list