[Mono-bugs] [Bug 621215] New: Generic casts are slow

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Jul 9 10:38:09 EDT 2010


http://bugzilla.novell.com/show_bug.cgi?id=621215

http://bugzilla.novell.com/show_bug.cgi?id=621215#c0


           Summary: Generic casts are slow
    Classification: Mono
           Product: Mono: Runtime
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: JIT
        AssignedTo: lupus at novell.com
        ReportedBy: msafar at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


using System;
using System.Diagnostics;
using System.Collections.Generic;

class A
{
}

class Test : A
{
    static T TestMethod<T> (A a) where T : A
    {
        T t = null;
        for (int i = 0; i < 10000000; ++i)
            t = (T) a;

        return t;
    }


    public static void Main ()
    {
        A target = new Test ();

        var sw = new Stopwatch ();
        sw.Start ();
        TestMethod<Test> (target);
        sw.Stop ();
        Console.WriteLine (sw.ElapsedMilliseconds);
        Console.WriteLine (target.ToString ());
    }
}

The result on 32-bits

Mono: 480
NET 4.0: 90

That's about 5x slower.

-- 
Configure bugmail: http://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