473,385 Members | 1,392 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

benchmarks? java vs .net

The shootout site has benchmarks comparing different languages. It
includes C# Mono vs Java but not C# .NET vs Java. So I went through
all the benchmark on the site ...

http://kingrazi.blogspot.com/2008/05...enchmarks.html

Just to keep the post on topic for my friends at comp.lang.c++, how do
I play default windows sounds with C++?

Jun 27 '08 #1
318 10696
King Raz wrote:
The shootout site has benchmarks comparing different languages. It
includes C# Mono vs Java but not C# .NET vs Java. So I went through
all the benchmark on the site ...

http://kingrazi.blogspot.com/2008/05...enchmarks.html

Just to keep the post on topic for my friends at comp.lang.c++, how do
I play default windows sounds with C++?
This guy had trolled the comp.lang.java.programmer and comp.lang.c++
newsgroup for many weeks with pretentious post about the performance
comparison of C++ and Java.
The comparison was done in a not scientific way with only purpose of get
replies.
To get replies he/she send many replies to each message he/she receives.

For reach is target he/she changed his/hers email address many times to
avoid killfiles.

I suggest the people not interested who have thunderbird to install the
"Right click ingore/watch thread" extension and use it for ignoring this
thread.

--
Andrea Francia
http://andreafrancia.blogspot.com/
Jun 27 '08 #2
On Sat, 31 May 2008 18:09:12 GMT, Andrea Francia
<an************@REMOVE-FROM-HERE.ohoihihoihoih.TO-HERE.gmx.itwrote:
>This guy had trolled the comp.lang.java.programmer and comp.lang.c++
newsgroup for many weeks with pretentious post about the performance
comparison of C++ and Java.
This got to be the funniest post. She (or is that he?) cross-posts
(spams?) three newsgroups with the subject "Please don't feed the
troll" and this post was the only response to my thread. Thanks for
feeding me. She/He also quotes my entire post so anyone who missed my
first post now read it :) Now I know at least one person read my
post; that is the brilliant: Andrea Francia, for Italy :)

Were you born this stupid or did someone hit you with a baseball bal?

Jun 27 '08 #3
On Sat, 31 May 2008 14:24:10 -0500, Razii <fg***@mail.comwrote:
>This got to be the funniest post. She (or is that he?) cross-posts
(spams?) three newsgroups with the subject "Please don't feed the
troll" and this post was the only response to my thread. Thanks for
feeding me. She/He also quotes my entire post so anyone who missed my
first post now read it :) Now I know at least one person read my
post; that is the brilliant: Andrea Francia, for Italy :)
Arrrgh. I meant "from Italy"

In any case, if you think I am a troll, why would you feed me by
responding to my post? Why would you quote my entire post, advertising
it for free? People who missed the first post now must have read my
post, thanks to Andrea Francia.

Well, it seems, the programming-related newsgroups have some of
the dumbest people on USENET. I wonder why?

Jun 27 '08 #4

Andrea Francia wrote:
I suggest...
!Thanks for the respam. I'd have never been aware of this
post had it not been for your announcement and sage advice.

I'm sure k.rzi thanks you for reposting a link to his site.
Jun 27 '08 #5
King Raz wrote:
The shootout site has benchmarks comparing different languages. It
includes C# Mono vs Java but not C# .NET vs Java. So I went through
all the benchmark on the site ...

http://kingrazi.blogspot.com/2008/05...enchmarks.html
>
Just to keep the post on topic for my friends at comp.lang.c++, how do
I play default windows sounds with C++?
Yes. I have ported a variety of benchmarks and found there is no significant
difference between the performance of .NET and Java. The one result that
stood out was .NET being 2x faster at the Mersenne Twister PRNG.

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
Jun 27 '08 #6
On Mon, 02 Jun 2008 10:22:29 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
>Yes. I have ported a variety of benchmarks and found there is no significant
difference between the performance of .NET and Java. The one result that
stood out was .NET being 2x faster at the Mersenne Twister PRNG.
..NET is twice slower in four benchmarks: binarytrees, mandelbrot,
regexdna, sumcol. .NET was twice faster only in trig related
benchmark.

Jun 27 '08 #7
Razii wrote:
On Mon, 02 Jun 2008 10:22:29 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
>>Yes. I have ported a variety of benchmarks and found there is no
significant difference between the performance of .NET and Java. The one
result that stood out was .NET being 2x faster at the Mersenne Twister
PRNG.

.NET is twice slower in four benchmarks: binarytrees, mandelbrot,
regexdna, sumcol. .NET was twice faster only in trig related
benchmark.
You have not optimized the .NET code:

On the mandelbrot benchmark, most of the time is spent doing unbuffered IO.
Use buffered IO and .NET becomes ~10% faster than Java.

On the regexdna benchmark, the regular expressions are not being compiled.
Ask for compilation and the .NET is <20% slower than Java.

The sumcol benchmark is also using unbuffered IO.

So neither VM is significantly faster overall.

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
Jun 27 '08 #8
On Tue, 03 Jun 2008 01:23:00 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
>On the mandelbrot benchmark, most of the time is spent doing unbuffered IO.
Use buffered IO and .NET becomes ~10% faster than Java.
The output was directed to /NULL so I don't see how buffering makes
the difference. In any case, post the version that makes it 10%
faster. Right now it's 2 times slower.
>On the regexdna benchmark, the regular expressions are not being compiled.
Ask for compilation and the .NET is <20% slower than Java.
The version that compiles regex is slower that then the version that
doesn't compile on Mono

http://shootout.alioth.debian.org/gp...exdna&lang=all

That's because the regular expression is used only once and compiling
it makes it slower. I doubt the compiled version will be faster on
..NET. It will be slower.
>The sumcol benchmark is also using unbuffered IO.
Post the right version that buffers then.
>So neither VM is significantly faster overall.
..NET is 2 times slower in 4 of the benchmarks. Post the version that
makes it faster so we can verify. You haven't done it yet.

Jun 27 '08 #9
On Mon, 02 Jun 2008 20:21:04 -0500, Razii <kl*******@mail.comwrote:
>The version that compiles regex is slower that then the version that
doesn't compile on Mono

http://shootout.alioth.debian.org/gp...exdna&lang=all
Ok, I did try compiled version on .NET and it was faster than
uncompiled version.

9.539s (uncompiled)
5.165s (compiled)

the java version was 3.956s
Jun 27 '08 #10
On Tue, 03 Jun 2008 01:23:00 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
>The sumcol benchmark is also using unbuffered IO.
I changed the line to

using (StreamReader r = new
StreamReader(Console.OpenStandardInput(8192)))

Buffereing 8192 bytes now?

It made no difference.

4.861s (unbuffered)
4.839s (buffered)

still two times slower.

Jun 27 '08 #11
On Tue, 03 Jun 2008 01:23:00 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
>On the mandelbrot benchmark, most of the time is spent doing unbuffered IO.
Use buffered IO and .NET becomes ~10% faster than Java.
Doesn't this line mean

http://shootout.alioth.debian.org/gp...ng=csharp&id=2

Stream s = Console.OpenStandardOutput(1024);

it's buffering already, 1024 bytes?

vs this java version

http://shootout.alioth.debian.org/gp...ng=javaxx&id=0

it's 3.4 times slower.

Jun 27 '08 #12
Jon Harrop wrote:
Razii wrote:
>On Mon, 02 Jun 2008 10:22:29 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
>>Yes. I have ported a variety of benchmarks and found there is no
significant difference between the performance of .NET and Java. The one
result that stood out was .NET being 2x faster at the Mersenne Twister
PRNG.
.NET is twice slower in four benchmarks: binarytrees, mandelbrot,
regexdna, sumcol. .NET was twice faster only in trig related
benchmark.

You have not optimized the .NET code:

On the mandelbrot benchmark, most of the time is spent doing unbuffered IO.
Use buffered IO and .NET becomes ~10% faster than Java.

On the regexdna benchmark, the regular expressions are not being compiled.
Ask for compilation and the .NET is <20% slower than Java.

The sumcol benchmark is also using unbuffered IO.

So neither VM is significantly faster overall.
Rather amusing really as unintentional use of unbuffered IO is a
frequent cause of Java benchmarks running more slowly than they should.
It seems that .NET copied that characteristic as well.

Mark Thornton
Jun 27 '08 #13
Mark Thornton wrote:
Rather amusing really as unintentional use of unbuffered IO is a
frequent cause of Java benchmarks running more slowly than they should.
It seems that .NET copied that characteristic as well.
Yes. I've no idea why they do that. Isn't buffered IO a better default?!

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
Jun 27 '08 #14
On Tue, 03 Jun 2008 07:55:07 +0100, Mark Thornton
<mt*******@optrak.co.ukwrote:
>Rather amusing really as unintentional use of unbuffered IO is a
frequent cause of Java benchmarks running more slowly than they should.
It seems that .NET copied that characteristic as well.
Harpo was wrong though. mandelbrot is buffered

Stream s = Console.OpenStandardOutput(1024);

It's still 3.4 times slower.

Verify it yourself.

http://shootout.alioth.debian.org/gp...ng=csharp&id=2

vs

http://shootout.alioth.debian.org/gp...ng=javaxx&id=0
3.4 times slower.

Jun 27 '08 #15
Razii wrote:
On Tue, 03 Jun 2008 01:23:00 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
>>On the mandelbrot benchmark, most of the time is spent doing unbuffered
IO. Use buffered IO and .NET becomes ~10% faster than Java.

The output was directed to /NULL so I don't see how buffering makes
the difference. In any case, post the version that makes it 10%
faster. Right now it's 2 times slower.
Change:

Stream s = Console.OpenStandardOutput(1024);

to:

BufferedStream s = new BufferedStream(Console.OpenStandardOutput());

and the entire program becomes 2.5x faster.
>>On the regexdna benchmark, the regular expressions are not being compiled.
Ask for compilation and the .NET is <20% slower than Java.

Ok, I did try compiled version on .NET and it was faster than
uncompiled version.

9.539s (uncompiled)
5.165s (compiled)

the java version was 3.956s
Yes.
>>So neither VM is significantly faster overall.

.NET is 2 times slower in 4 of the benchmarks.
Java is only 2x faster in one benchmark (binarytrees) here and that is not a
well formed benchmark. Java is still over 2x slower on both partialsums and
the Mersenne Twister.

So you cannot reasonably conclude that Java is faster.

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
Jun 27 '08 #16
Razii wrote:
On Tue, 03 Jun 2008 07:55:07 +0100, Mark Thornton
<mt*******@optrak.co.ukwrote:
>>Rather amusing really as unintentional use of unbuffered IO is a
frequent cause of Java benchmarks running more slowly than they should.
It seems that .NET copied that characteristic as well.

Harpo was wrong though. mandelbrot is buffered

Stream s = Console.OpenStandardOutput(1024);
Use:

BufferedStream s = new BufferedStream(Console.OpenStandardOutput());
It's still 3.4 times slower.
Not if you optimize it properly.
Verify it yourself.
I did.

There is no merit in comparing unoptimized code on .NET with optimized Java.

Java is also not significant faster on any of the SciMark2 benchmarks. The
only significant difference I have seen is on the Mersenne Twister PRNG
where Java is 2x slower than .NET.

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
Jun 27 '08 #17
In article <ep********************************@4ax.com>,
Razii <kl************@mail.comwrote:

[...]
Verify it yourself.

http://shootout.alioth.debian.org/gp...rot&lang=cshar
p&id=2

vs

http://shootout.alioth.debian.org/gp...rot&lang=javax
x&id=0
3.4 times slower.
Indeed, I see C#/Mono = 7.15s and Java = 3.22s. I would say that Java
took (3.22s / 7.15s = 0.450) less that half as long as C#/Mono or that
Java was (7.15s / 3.22s = 2.220) over twice as fast. I don't see where
3.4 comes from. Just asking.

John
--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews
Jun 27 '08 #18
John B. Matthews wrote:
Indeed, I see C#/Mono = 7.15s and Java = 3.22s. I would say that Java
took (3.22s / 7.15s = 0.450) less that half as long as C#/Mono or that
Java was (7.15s / 3.22s = 2.220) over twice as fast. I don't see where
3.4 comes from. Just asking.
FWIW, F#/Mono is 3x slower than F#/.NET on the SciMark2 benchmark. I'd like
to know how performance compares between these platforms for parallel code.

Does Java have anything comparable to .NET's Task Parallel Library?

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
Jun 27 '08 #19
On Jun 3, 4:39 pm, Jon Harrop <j...@ffconsultancy.comwrote:
FWIW, F#/Mono is 3x slower than F#/.NET on the SciMark2 benchmark. I'd like
to know how performance compares between these platforms for parallel code.
If Razii is genuinely comparing Java with Mono (I haven't looked at
any of the figures) it's a silly test to start with (unless you're
specifically interested in Mono, of course). The vast majority of C#
code runs on .NET rather than Mono - and while I applaud the Mono
team's work, I seriously doubt that it has quite has much effort going
into it as Microsoft is putting into .NET. I'd expect .NET to
outperform Mono, and on microbencharks like these the difference could
be quite significant in some cases.
Does Java have anything comparable to .NET's Task Parallel Library?
I haven't used it, but I've heard about Doug Lea's Fork/Join
framework:
http://gee.cs.oswego.edu/dl/papers/fj.pdf

One problem with creating anything like Parallel Extensions (which I
assume is what you meant - AFAIK the TPL is just part of Parallel
Extensions, although I could be misunderstanding you completely) for
Java is that it doesn't (currently) have closures other than anonymous
inner classes which are ugly as hell.

The state of closures in Java 7 is currently up in the air.

Jon
Jun 27 '08 #20
On Tue, 03 Jun 2008 16:08:17 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
Java is still over 2x slower on both partialsums and
the Mersenne Twister.
The partialsums is only slower due to trig accuracy required by Java's
specification. Your C# results are not accurate enough to satisfy
Java's specification. It's easy to solve this problem. Try this Java
version of partialsums. It's two times faster.

http://shootout.alioth.debian.org/gp...lang=java&id=4

In binarytrees C# is twice slower. You haven't posted any workaround
yet.

Jun 27 '08 #21
On Tue, 03 Jun 2008 11:33:35 -0400, "John B. Matthews"
<no****@nospam.comwrote:
>I don't see where
3.4 comes from. Just asking.
Did you use -server flag? It's 7.578 vs 2.198 on my computer.
7.578 / 2.198 = 3.44
Jun 27 '08 #22
On Tue, 03 Jun 2008 16:08:17 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
BufferedStream s = new BufferedStream(Console.OpenStandardOutput());

and the entire program becomes 2.5x faster.
Yes, that was faster. I submitted it to shootout site. I am not sure
if it will be faster on Mono too but I will let Gouy test it.
Jun 27 '08 #23
On Tue, 03 Jun 2008 16:18:34 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
>There is no merit in comparing unoptimized code on .NET with optimized Java.
That's why posted it here so you can "optimize it". You fixed
mandelbrot but C# is still twice slower in three other benchmarks:

binarytrees
(the command line argument should be -server -Xms64m binarytrees)

http://shootout.alioth.debian.org/gp...ng=javaxx&id=2
vs
http://shootout.alioth.debian.org/gp...ng=csharp&id=0
revcomp
http://shootout.alioth.debian.org/gp...ng=javaxx&id=4
vs
http://shootout.alioth.debian.org/gp...ng=csharp&id=2
sumcol
http://shootout.alioth.debian.org/gp...ng=javaxx&id=4
vs
http://shootout.alioth.debian.org/gp...ng=csharp&id=0
also, C# significantly slower in recursion

http://shootout.alioth.debian.org/gp...ng=javaxx&id=0
vs
http://shootout.alioth.debian.org/gp...ng=csharp&id=0

>I have seen is on the Mersenne Twister PRNG where Java is 2x slower than .NET.
Post the benchmark. Let me see...
Jun 27 '08 #24
On Tue, 3 Jun 2008 09:19:22 -0700 (PDT), "Jon Skeet [C# MVP]"
<sk***@pobox.comwrote:
>If Razii is genuinely comparing Java with Mono (I haven't looked at
any of the figures) it's a silly test to start with (unless you're
specifically interested in Mono, of course).
If you have no clue what is this thread about, why post at all?

Jun 27 '08 #25
Razii <kl*****@mail.comwrote:
If Razii is genuinely comparing Java with Mono (I haven't looked at
any of the figures) it's a silly test to start with (unless you're
specifically interested in Mono, of course).

If you have no clue what is this thread about, why post at all?
Well gee, you keep post URLs comparing Mono with Java. That's *not*
comparing .NET with Java - and is thus relatively pointless IMO. (It's
also made more pointless by you not mentioning in your blog post which
version of Java you're using, or which version of .NET.)

To make the conversation significant (well, as significant as this kind
of thing can be):

1) Don't bother posting about the Mono benchmarks at all. Keep it to
.NET and Java.
2) Explain the precise runtime environments.

The IO suggestions so far seem to be an indication of the general merit
of the benchmark, mind you.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #26
On Tue, 3 Jun 2008 18:51:10 +0100, Jon Skeet [C# MVP]
<sk***@pobox.comwrote:
>Well gee, you keep post URLs comparing Mono with Java. That's *not*
comparing .NET with Java - and is thus relatively pointless IMO. (It's
also made more pointless by you not mentioning in your blog post which
version of Java you're using, or which version of .NET.)
The link I posted was this:

http://kingrazi.blogspot.com/

It's clear what it is about.
Jun 27 '08 #27
Razii wrote:
On Tue, 03 Jun 2008 16:08:17 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
> BufferedStream s = new BufferedStream(Console.OpenStandardOutput());

and the entire program becomes 2.5x faster.

Yes, that was faster. I submitted it to shootout site. I am not sure
if it will be faster on Mono too but I will let Gouy test it.
It makes no difference on Mono and the shootout does not test .NET.

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
Jun 27 '08 #28
On Tue, 3 Jun 2008 18:51:10 +0100, Jon Skeet [C# MVP]
<sk***@pobox.comwrote:
>The IO suggestions so far seem to be an indication of the general merit
of the benchmark, mind you.
The criteria is same for both sides. For now C# is slower by wide
margin in these benchmarks. How about fixing them? If you can't, I
will conclude C# is just slower.

binarytrees
(the command line argument should be -server -Xms64m binarytrees)

http://shootout.alioth.debian.org/gp...ng=javaxx&id=2
vs
http://shootout.alioth.debian.org/gp...ng=csharp&id=0
revcomp
http://shootout.alioth.debian.org/gp...ng=javaxx&id=4
vs
http://shootout.alioth.debian.org/gp...ng=csharp&id=2
sumcol
http://shootout.alioth.debian.org/gp...ng=javaxx&id=4
vs
http://shootout.alioth.debian.org/gp...ng=csharp&id=0
also, C# significantly slower in recursion

http://shootout.alioth.debian.org/gp...ng=javaxx&id=0
vs
http://shootout.alioth.debian.org/gp...ng=csharp&id=0

Jun 27 '08 #29
Jon Harrop wrote:
Mark Thornton wrote:
>Rather amusing really as unintentional use of unbuffered IO is a
frequent cause of Java benchmarks running more slowly than they should.
It seems that .NET copied that characteristic as well.

Yes. I've no idea why they do that. Isn't buffered IO a better default?!
I think the reasoning is simplicity --- you create what you want through
composition of a smaller number of classes. Otherwise you need more
classes or extra options on constructors to provide for all possible
cases. Unfortunately they spoiled this a bit by providing a few
composites (java.io.FileReader for example). It is also a bit confusing
that InputStreamReader includes some buffering, but adding buffering to
an already buffered stream doesn't usually increase the cost by much.

Mark Thornton
Jun 27 '08 #30
Razii wrote:
The criteria is same for both sides. For now C# is slower by wide
margin in these benchmarks. How about fixing them?
I did.
If you can't, I will conclude C# is just slower.
You had drawn that conclusion before you even tried to measure anything.

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
Jun 27 '08 #31
Jon Skeet [C# MVP] wrote:
>
>Does Java have anything comparable to .NET's Task Parallel Library?

I haven't used it, but I've heard about Doug Lea's Fork/Join
framework:
http://gee.cs.oswego.edu/dl/papers/fj.pdf
I have used it and find it works quite well even without closures. I
haven't used .NET so can't compare them.

For more information and downloads of the package:
http://g.oswego.edu/dl/concurrency-interest/

Mark Thornton
Jun 27 '08 #32
Razii <kl*****@mail.comwrote:
On Tue, 3 Jun 2008 18:51:10 +0100, Jon Skeet [C# MVP]
<sk***@pobox.comwrote:
Well gee, you keep post URLs comparing Mono with Java. That's *not*
comparing .NET with Java - and is thus relatively pointless IMO. (It's
also made more pointless by you not mentioning in your blog post which
version of Java you're using, or which version of .NET.)

The link I posted was this:

http://kingrazi.blogspot.com/

It's clear what it is about.
That was the link you posted *initially*. Since then you have posted
multiple links to http://shootout.alioth.debian.org which is about
Mono.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #33
Mark Thornton wrote:
Jon Skeet [C# MVP] wrote:
>>Does Java have anything comparable to .NET's Task Parallel Library?

I haven't used it, but I've heard about Doug Lea's Fork/Join
framework:
http://gee.cs.oswego.edu/dl/papers/fj.pdf
I have used it and find it works quite well even without closures. I
haven't used .NET so can't compare them.
The Task Parallel Library is awesome, even though it is only a CTP for now.
I highly recommend it. For example, read the article:

"Surviving in the multicore era with Microsoft's ParallelFX" - The F#.NET
Journal, 30th April 2008
http://www.ffconsultancy.com/product...rp_journal/?cs

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
Jun 27 '08 #34
Razii wrote:
On Tue, 03 Jun 2008 16:08:17 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
>Java is still over 2x slower on both partialsums and
the Mersenne Twister.

The partialsums is only slower due to trig accuracy required by Java's
specification. Your C# results are not accurate enough to satisfy
Java's specification. It's easy to solve this problem. Try this Java
version of partialsums. It's two times faster.
But still 2x slower than everything else and now 2x more bloated as well:

C 1.300s
C# 1.363s
Java 2.750s
Java 3.840s (original)
In binarytrees C# is twice slower. You haven't posted any workaround
yet.
Optimizing binarytrees is trivial because the benchmark is fundamentally
flawed. I described this in detail on the shootout mailing list and urged
the maintainers to persue well defined benchmarks but they did not take
heed.

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
Jun 27 '08 #35
On Tue, 03 Jun 2008 19:37:57 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
>But still 2x slower than everything else and now 2x more bloated as well:

C 1.300s
C# 1.363s
Java 2.750s
that's not what I get

time java -server partialsums 2500000

0m1.697s

and for Mono I get

0m1.525s

Jun 27 '08 #36
Razii <kl*****@mail.comwrote:
The IO suggestions so far seem to be an indication of the general merit
of the benchmark, mind you.

The criteria is same for both sides.
Um, the C# version (as posted on the site you've linked to below) uses
unbuffered IO while the Java version doesn't. They're just not doing
the same thing. Even if they were, that wouldn't give any meaningful
data about which language/platform "in general". It might help if you
happen to know that your code is going to require a huge amount of
recursion - to the extent that it's going to be the performance
bottleneck - *and* performance is your primary concern.
For now C# is slower by wide margin in these benchmarks. How about
fixing them? If you can't, I will conclude C# is just slower.
Feel free to draw that conclusion, while the rest of us instead
conclude that you can't claim that C# (which is a *language* after all,
not a platform) is slower or faster than another language.

Even running .NET rather than Mono will only go so far - you'd need to
run it on both 64 bit and 32 bit platforms, as the runtimes do
different things. (IIRC the 64 bit CLR uses tail recursion more heavily
than the 32 bit CLR, for instance.)

If I were to find a really slow JVM, would that prove that Java is a
slower *language* than C#?

I can easily write a benchmark where Java (under Hotspot) "beats" .NET:
just call a very small virtual method which is never overridden.
Hotspot will inline the call aggressively, as it is able to "undo" the
optimisation later on. .NET, with a single-pass JIT, won't do that.
Does that prove that Java is a faster language? No, not at all. It just
shows one area situation where it works better. It pretty much has to,
given that far more methods tend to be virtual in Java code than in
..NET code. I can probably find similar situations where .NET stomps
over Java (being able to create custom value types would probably be a
good starting point - force heap allocation and garbage collection in
Java but not .NET; even though it's fast, it's not free) - but that
wouldn't prove that .NET is faster than Java, either.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #37
Razii wrote:
On Tue, 03 Jun 2008 19:37:57 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
>>But still 2x slower than everything else and now 2x more bloated as well:

C 1.300s
C# 1.363s
Java 2.750s

that's not what I get

time java -server partialsums 2500000

0m1.697s

and for Mono I get

0m1.525s
Yes. Mono is extremely slow. Almost as slow as Java on this benchmark. As we
have seen, .NET is much faster...

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
Jun 27 '08 #38
On Tue, 03 Jun 2008 19:33:41 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
>If you can't, I will conclude C# is just slower.

You had drawn that conclusion before you even tried to measure anything.
What the heck? I measured everything and posted the linhk. That's how
the thread started.

BufferedStream didn't help in sumcol

using (StreamReader r = new StreamReader(new
BufferedStream(Console.OpenStandardInput())))

makes no difference.

The only fix you have made so far is to mandelbrot. What about the 4
other I mentioned?

Jun 27 '08 #39
Mark Thornton <mt*******@optrak.co.ukwrote:
I haven't used it, but I've heard about Doug Lea's Fork/Join
framework:
http://gee.cs.oswego.edu/dl/papers/fj.pdf

I have used it and find it works quite well even without closures.
Cool - that's good to hear. I'd be very surprised if closures didn't
make it even simpler to use (possibly with a bit of refactoring towards
single-method interfaces if necessary).

Given the rest of Doug Lea's work, I'd expect it to be good :)
I haven't used .NET so can't compare them.
Here's a little example from a Mandelbrot benchmark I was writing a few
weeks ago (oh the irony).

Simple initial code:

public override void Generate()
{
int index = 0;
for (int row = 0; row < Height; row++)
{
for (int col = 0; col < Width; col++)
{
Data[index++] = ComputeMandelbrotIndex(row, col);
}
}
}

Now using Parallel Extensions, and the lamdba expressions of C# 3:

public override void Generate()
{
Parallel.For(0, Height, row =>
{
int index = row * Width;
for (int col = 0; col < Width; col++)
{
Data[index++] = ComputeMandelbrotIndex(row, col);
}
});
}

I can't imagine many transformations being simpler than that - and the
results are great.

See http://preview.tinyurl.com/58vfav for rather more :)
For more information and downloads of the package:
http://g.oswego.edu/dl/concurrency-interest/
Thanks, will take a look.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #40
On Tue, 3 Jun 2008 19:37:47 +0100, Jon Skeet [C# MVP]
<sk***@pobox.comwrote:
>That was the link you posted *initially*. Since then you have posted
multiple links to http://shootout.alioth.debian.org which is about
Mono.
Huh? I will be polite for now and just say you didn't read the thread
carefully. The benchmark I tested are at that site. I don't have Mono.
I only have .NET.


Jun 27 '08 #41
On Tue, 03 Jun 2008 19:37:57 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
>But still 2x slower than everything else and now 2x more bloated as well:
The FastMath class can be separated and used instead of java's Math in
all cases. The bloat is ZERO.
Jun 27 '08 #42
Jon Harrop <jo*@ffconsultancy.comwrote:
Mark Thornton wrote:
Jon Skeet [C# MVP] wrote:
>Does Java have anything comparable to .NET's Task Parallel Library?

I haven't used it, but I've heard about Doug Lea's Fork/Join
framework:
http://gee.cs.oswego.edu/dl/papers/fj.pdf
I have used it and find it works quite well even without closures. I
haven't used .NET so can't compare them.

The Task Parallel Library is awesome, even though it is only a CTP for now.
Agreed. Now is a particularly good time to get into it, as the second
CTP has just been released:

http://blogs.msdn.com/pfxteam/archiv...2/8567093.aspx
I highly recommend it. For example, read the article:

"Surviving in the multicore era with Microsoft's ParallelFX" - The F#.NET
Journal, 30th April 2008
http://www.ffconsultancy.com/product...rp_journal/?cs
Or not, given that that's subscription only...

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #43
On Tue, 03 Jun 2008 19:48:16 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
>Yes. Mono is extremely slow. Almost as slow as Java on this benchmark. As we
have seen, .NET is much faster...
That was a typo. I don't have Mono. I get that with .NET.
Jun 27 '08 #44
On Tue, 3 Jun 2008 19:50:21 +0100, Jon Skeet [C# MVP]
<sk***@pobox.comwrote:
>Um, the C# version (as posted on the site you've linked to below) uses
unbuffered IO while the Java version doesn't. They're just not doing
the same thing.
What benchmark are you talking about? Changing the line to

using (StreamReader r = new StreamReader(new
BufferedStream(Console.OpenStandardInput())))

didn't make a difference in sum-file benchmark.

By the way, StreamTokenizer is not buffered. It reads a byte each time
from the stream. It maybe that System.in is buffered by default in
Java.

Jun 27 '08 #45

On Tue, 03 Jun 2008 19:37:57 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
>But still 2x slower than everything else and now 2x more bloated as well:
The FastMath class can be separated and used instead of java's Math in
all cases. The bloat is ZERO.
Jun 27 '08 #46
Razii wrote:
On Tue, 03 Jun 2008 19:48:16 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
>>Yes. Mono is extremely slow. Almost as slow as Java on this benchmark. As
we have seen, .NET is much faster...

That was a typo. I don't have Mono. I get that with .NET.
Java is 2x slower than .NET on my AMD64 for this benchmark. What CPU are you
using?

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
Jun 27 '08 #47
Razii wrote:
On Tue, 03 Jun 2008 19:37:57 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
>>But still 2x slower than everything else and now 2x more bloated as well:

The FastMath class can be separated and used instead of java's Math in
all cases. The bloat is ZERO.
So having to write your own basic trig functions in Java so that you can be
only 2x slower than other languages doesn't bother you?

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
Jun 27 '08 #48
Razii <kl*****@mail.comwrote:
That was the link you posted *initially*. Since then you have posted
multiple links to http://shootout.alioth.debian.org which is about
Mono.

Huh? I will be polite for now and just say you didn't read the thread
carefully. The benchmark I tested are at that site. I don't have Mono.
I only have .NET.
Let's look at the most recent set of links you posted to "prove" that
Java is faster than C#:

http://shootout.alioth.debian.org/gp...benchmark.php?
test=binarytrees&lang=javaxx&id=2

http://shootout.alioth.debian.org/gp...benchmark.php?
test=binarytrees&lang=csharp&id=0
revcomp
http://shootout.alioth.debian.org/gp...benchmark.php?
test=revcomp&lang=javaxx&id=4
vs
http://shootout.alioth.debian.org/gp...benchmark.php?
test=revcomp&lang=csharp&id=2
sumcol
http://shootout.alioth.debian.org/gp...benchmark.php?
test=sumcol&lang=javaxx&id=4
vs
http://shootout.alioth.debian.org/gp...benchmark.php?
test=sumcol&lang=csharp&id=0

http://shootout.alioth.debian.org/gp...benchmark.php?
test=recursive&lang=javaxx&id=0
vs
http://shootout.alioth.debian.org/gp...benchmark.php?
test=recursive&lang=csharp&id=0
Now, you're using *those results* to form conclusions, right? If not,
there was little point in posting them. However, those results are of
Mono, not .NET.

This is why I've urged consistency. What's the point in debating Java
vs .NET if you keep posting links to results of Java vs Mono?

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #49
On Tue, 03 Jun 2008 20:05:33 +0100, Jon Harrop <jo*@ffconsultancy.com>
wrote:
>Java is 2x slower than .NET on my AMD64 for this benchmark. What CPU are you
using?
AMD 3 core phenom

Are you sure you used this version?

http://shootout.alioth.debian.org/gp...lang=java&id=4

$ time partialsums 2500000 (.NET)
3.000000000 (2/3)^k
3160.817621887 k^-0.5
0.999999600 1/k(k+1)
30.314541510 Flint Hills
42.995233998 Cookson Hills
15.309017155 Harmonic
1.644933667 Riemann Zeta
0.693146981 Alternating Harmonic
0.785398063 Gregory

real 0m1.530s
user 0m0.000s
sys 0m0.031s

$ time java -server partialsums 2500000
3.000000000 (2/3)^k
3160.817621887 k^-0.5
0.999999600 1/k(k+1)
30.314541510 Flint Hills
42.995233998 Cookson Hills
15.309017155 Harmonic
1.644933667 Riemann Zeta
0.693146981 Alternating Harmonic
0.785398063 Gregory

real 0m1.697s
user 0m0.000s
sys 0m0.031s

Jun 27 '08 #50

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

80
by: tech | last post by:
Hi, i have the following problem In file1.h namespace A { class Bar { void foo();
358
by: King Raz | last post by:
The shootout site has benchmarks comparing different languages. It includes C# Mono vs Java but not C# .NET vs Java. So I went through all the benchmark on the site ... ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.