Rolf Bjarne Kvinge
Fri, 29 Jan 2010 08:30:02 -0800
Hi, Can you post the source code for the java sample? I have a hard time understanding how the sample can run so fast with java, here I get the following results:
C#: 3.346 seconds C (compiled with gcc O3, see attached source code): 1.132 seconds Rolf >Hi, > >I'm quite familiar with both the .NET and Java development environments, but only recently have begun to experiment with mono, so forgive me if I'm not clued-in. > >I specialize in numerical work that often involves a lot large-scale array manipulation for linear algebra, timeseries, etc. My main production platforms are OSX and Linux. I've been doing most of my work on the JVM over the >past few years, though spent a couple of years with .NET when it was pre-release / pre-1.0. > >My main interest is in Ocaml, particularly the F# variant as the basis for my numerical work. > >One of the first things I do when considering a platform is run benchmarks, as performance is critical for what I do. Starting with C# I wrote a test to gauge the array-access overhead associated with the platform. Without >knowing how to tweak the mono runtime to turn on any particular optimisations, the results were quite poor for this specific test (see code at the end of this posting). > > >The test on my MacPro 2.6 Ghz / Snow Leopard with mono 2.6.1 gave the result of: > > 16 sec, 130 ms for 1000 iterations > >the same code, modified just for IO, etc on the Java VM (without -server) gave a runtime of: > > 0 sec, 831 ms > >changing the # of iterations to higher amounts did nothing to improve the ratio. Java is 20x faster in this benchmark. > >I could not find any documentation concerning settings for the -optimize flag on the mono VM, so perhaps there is a setting I should be using. > >Secondly, I saw the posting concerning the optional use of LLVM. I have not been able to build mono on OSX as am having problems building glib. I'm wondering whether anyone has a packaged up version of glib or better a packaged up >version of mono with LLVM enabled. > >I have heard only good things about LLVM performance, so hoping that this will help address this gap. Hopefully I am doing something wrong here and the performance is much closer. Test code below ... > >regards > >Jonathan -- http://tr8dr.wordpress.com/
#include <stdio.h>
#include <string.h>
double test1 (double *vec, int length)
{
double sum = 0;
int i, j;
for (i = 8; i < length; i++) {
vec [i] = 2 * vec [i] - vec [i-1];
for (j = 1; j < 8; j++)
sum += 1.3 * vec [j - 1];
}
return sum;
}
int main (int argc, char **argv)
{
const int iterations = 1000;
const int length = 100000;
double *vec = malloc (length * sizeof (double));
int i;
for (i = 0; i < length; i++) {
vec [i] = i;
}
double sum = 0;
for (i = 0; i < iterations; i++)
sum += test1 (vec, length);
printf ("result: %f\n", sum);
}_______________________________________________ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list