[Mono-bugs] [Bug 367354] New: Type.GetTypeCode() is slow

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Mar 5 10:09:04 EST 2008


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


           Summary: Type.GetTypeCode() is slow
           Product: Mono: Runtime
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Enhancement
          Priority: P5 - None
         Component: misc
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: juraj at hotfeet.ch
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


I tried comparing the performance of the following 3 methods (test case is
attached):

static bool IsInt (Type t) {
        return
                t == typeof (byte) || t == typeof (sbyte) ||
                t == typeof (short) || t == typeof (ushort) ||
                t == typeof (int) || t == typeof (uint) ||
                t == typeof (long) || t == typeof (ulong);
}

static bool IsInt2 (Type t) {
        TypeCode tc = Type.GetTypeCode(t);
        switch(tc) {
        case TypeCode.SByte:
        case TypeCode.Byte:
        case TypeCode.Int16:
        case TypeCode.UInt16:
        case TypeCode.Int32:
        case TypeCode.UInt32:
        case TypeCode.Int64:
        case TypeCode.UInt64:
                return true;
        default:
                return false;
        }
}

static bool IsInt3 (Type t) {
        TypeCode tc = Type.GetTypeCode(t);
        return TypeCode.SByte <= tc && tc <= TypeCode.UInt64; 
}

These are the test result on Mono and MS.NET:

Mono (on a fast PC):
--------------------
mono typecode.exe 1000000
203,081
1,455,844
1,491,576

MS.NET (on a slow PC):
----------------------
typecode 1000000
7'433'671
1'231'011
1'169'947


It seems as if our implementation of Type.GetTypeCode() is rather slow. Could
the code in ves_icall_type_GetTypeCodeInternal (MonoReflectionType *type) (in
mono/metadata/icalls.c) be moved to the managed world? Do we have access to
type->type->type?


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


More information about the mono-bugs mailing list