[Mono-bugs] [Bug 371722] New: Mono array initialization 10x slower than .NET

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Mar 17 08:30:28 EDT 2008


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


           Summary: Mono array initialization 10x slower than .NET
           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: ---


1. compile and run following micro benchmark

using System;
using System.Diagnostics;

namespace N
{
        class C
        {
                private byte _d;
                private byte _e;
                private byte _f;
                private byte _g;
                private byte _h;
                private byte _i;
                private byte _j;
                private byte _k;

                public C ()
                {
                        _d = 30;
                        _e = 60;
                        _f = 90;
                        _g = 100;
                        _h = 130;
                        _i = 160;
                        _j = 190;
                        _k = 220;
                }

                private static char ToHex (int b)
                {
                        return (char) ((b < 0xA) ? ('0' + b) : ('a' + b -
0xA));
                }

                public char[] BaseToString (bool h, bool p, bool b)
                {
                        char[] vals1 = {
                                ToHex((_d >> 4) & 0xf),
                                ToHex(_d & 0xf),
                                ToHex((_e >> 4) & 0xf),
                                ToHex(_e & 0xf),
                                ToHex((_f >> 4) & 0xf),
                                ToHex(_f & 0xf),
                                ToHex((_g >> 4) & 0xf),
                                ToHex(_g & 0xf),
                                ToHex((_h >> 4) & 0xf),
                                ToHex(_h & 0xf),
                                ToHex((_i >> 4) & 0xf),
                                ToHex(_i & 0xf),
                                ToHex((_j >> 4) & 0xf),
                                ToHex(_j & 0xf),
                                ToHex((_k >> 4) & 0xf),
                                ToHex(_k & 0xf)
                        };

                        return vals1;
                }
        }

        class Program
        {
                static void Main (string [] args)
                {
                        Stopwatch sw = new Stopwatch ();
                        C c = new C ();
                        sw.Start ();
                        for (int i = 0; i < 10000000; ++i)
                                c.BaseToString (true, false, false);

                        sw.Stop ();
                        Console.WriteLine (sw.Elapsed);
                }
        }
}


Result:

Mono: ~3.50 seconds
NET: ~0.37 seconds


-- 
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