[Mono-list] Performance benchmark
Rodrigo Kumpera
kumpera at gmail.com
Fri Feb 26 16:19:25 EST 2010
On Fri, Feb 26, 2010 at 5:53 PM, JCKodel <jckodel at gmail.com> wrote:
>
> First of all, this is NOT a "native MS .net framework is better" e-mail.
>
> I want to build a huge cross-platform system, and I'm a .net programmer
> since, well, ever =) so making something in .net running on all major
> platforms would be heaven for me =) (not really many good results with
> Adobe
> AIR, RealBasic, Lazaro, etc.)
>
> So, I run a very dumb and simple test to check out if there were some
> performance issue with mono. I'm using the latest stable release on both
> Windows and Linux machines (didn't tested on Mac yet) and I'm getting a 10x
> slower results for mono =(
>
> The tests are very simple, although the code itself is not well written
> (that was made on purpose). I know I can do the math way better and using
> some other constructs on strings that are waaaay faster than raw strings.
> The point is to force the memory manipulation, type converters and float
> point calculations.
>
> So, am I doing something wrong (in the sense of mono configuration or
> options), or there is any tips that I should be aware of to, at least,
> bring
> this difference for, say, 2x slower?
>
> The source code for test is simple:
>
> First, some stupid Math calculations:
>
> for (int ct = 0; ct < 1000000; ct++)
> {
> decimal d =
> Convert.ToDecimal(Math.Pow(ct, 4));
> d =
> Convert.ToDecimal(Math.Sqrt(Convert.ToDouble(d)) * 4 *
> Math.Atan(Convert.ToDouble(ct)));
> }
>
> Then some memory play with raw strings:
>
> for (int ct = 0; ct < 100000; ct++)
> {
> string foo = "foo";
>
> for (int x = 1; x < 10; x++)
> {
> foo += " " +
> x.ToString("X2") + foo;
> }
>
> string bar = foo;
> foo += bar;
> }
>
>
> The results:
>
> Each test was done 3 times in a row. The numbers are milliseconds (lower,
> better):
>
>
> This is the executable generated by MonoDevelop, in Release configuration,
> running on a Windows 7 Console:
>
> Math: 535
> Strings: 2.038
> Math: 530
> Strings: 1.962
> Math: 530
> Strings: 1.963
>
> Using the mono.exe running the same executable above:
> Math: 6.875
> String: 6.206
> Math: 6.840
> String: 6.114
> Math: 6.857
> String: 6.116
>
> Running the same executable above using ./Benchmark.exe on a Ubuntu
> terminal
> running on a VirtualBox VM (not quite sure which mono version I'm running
> on
> this machine, anyway, is a VM and is running faster than mono.exe on native
> Windows):
>
>
There are a few things to notice. A virtualized machine will perform
significantly slower, specially
for CPU intensive workloads. You should try our live CD to get better
numbers.
Mono runs faster on linux than windows, but the virtualization has it's
costs.
To find our which version of mono you're running use "mono --version" on the
console. Since you're
using what comes with ubuntu it's most likely 2.4. The 2.6 release has some
performance improvements.
Now about your benchmark in particular. Mono has a significantly worse GC,
so any micro-benchmark
that stress this will show some significant performance degradation. We are
working on replacing it with
a generational copying collection (read very fast), but it won't be ready
any time soon.
The other point is that you didn't mention if you were testing under 32 or
64bits. Mono 32bits has a slower
FP implementation which shows up pretty badly. This is something that will
eventually be fixed.
Mono on real workloads is not 10x slower than MS, it comes to be 10-40%
slower on things like asp.net.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20100226/4fb6e7c0/attachment-0001.html
More information about the Mono-list
mailing list