473,581 Members | 2,755 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
358 13023
Mark Thornton <mt*******@optr ak.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++] = ComputeMandelbr otIndex(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++] = ComputeMandelbr otIndex(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.co m>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #51
Razii <kl*****@mail.c omwrote:
On Tue, 3 Jun 2008 19:50:21 +0100, Jon Skeet [C# MVP]
<sk***@pobox.co mwrote:
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?
The mandelbrot one. Look back in the thread from where I first talked
about IO, and you'll see it's the last one referenced.
Changing the line to

using (StreamReader r = new StreamReader(ne w
BufferedStream( Console.OpenSta ndardInput())))

didn't make a difference in sum-file benchmark.
The benchmark I wasn't referring to? Oh.
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.
Which benchmark are you talking about now? sum-file uses BufferedReader
but not StreamTokenizer as far as I can see.

It would be interesting to know what the sum-file benchmark is trying
to measure - there are six things off the top of my head:

1) File IO
2) Conversion from binary to text
3) Splitting a stream of textual data into lines
4) Parsing text into integers
5) Integer addition
6) Writing the result to the console

The benchmark gives no information as to which of those is the
bottleneck for any particular platform.

I note, by the way, that the Java version of sum-col assumes that using
the platform default encoding is good enough. The C# version always
uses UTF-8. Depending on what the default encoding is, that may or may
not be significant - but it does show that the programs are not doing
the same thing.
How did you measure your .NET results, by the way? By starting the
process thousands of times, as shown on the other web site, or by
running the same code within the process many times?

--
Jon Skeet - <sk***@pobox.co m>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #52
Razii <kl*****@mail.c omwrote:
$ 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
That looks very much like Unix output rather than Windows. Are you
running under cygwin or something similar?

It would really help if you gave a full explanation of how *you* (as
opposed to the shoot-out) site are running your tests.

(I'd also argue that benchmarks taking only a second and a half to
complete aren't likely to have a good startup vs running program
balance.)

--
Jon Skeet - <sk***@pobox.co m>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #53
Jon Skeet [C# MVP] wrote:
Mark Thornton <mt*******@optr ak.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++] = ComputeMandelbr otIndex(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++] = ComputeMandelbr otIndex(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.
There are some FJ examples here:
http://artisans-serverintellect-com....efault.asp?W32

The recursive matrix multiplication is my contribution.

Mark Thornton
Jun 27 '08 #54
Mark Thornton <mt*******@optr ak.co.ukwrote:

<snip>
There are some FJ examples here:
http://artisans-serverintellect-com....efault.asp?W32

The recursive matrix multiplication is my contribution.
Right. It still looks a bit involved - which is only to be expected,
really. I haven't taken it in fully yet though - will aim to do so at a
later date. Might try porting to Parallel Extensions...

--
Jon Skeet - <sk***@pobox.co m>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #55
On Tue, 03 Jun 2008 20:07:00 +0100, Jon Harrop <jo*@ffconsulta ncy.com>
wrote:
>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?
It's not 2x slower with my trig function on my computer.

On the other hand, C# results are not accurate for trig functions.

using System;
using System.IO;

class Test
{
static void Main(){
Console.WriteLi ne(Math.Sin (1e15));
}
}
The answer I get from C# is: 0.8582721324763 73

with Java I get 0.8582727931702 359

Checking the answer with maple, I get
0.8582727931702 358355238863908 484066466002034

How are you going to fix C# in this case?

Does it bother you that C# gave wrong answer?

Jun 27 '08 #56
On Tue, 3 Jun 2008 20:11:45 +0100, Jon Skeet [C# MVP]
<sk***@pobox.co mwrote:
>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.
Is this guy Jon Skeet really this stupid?

Let me know so I can add him to ignore list.


Jun 27 '08 #57
On Tue, 3 Jun 2008 20:27:19 +0100, Jon Skeet [C# MVP]
<sk***@pobox.co mwrote:
>That looks very much like Unix output rather than Windows. Are you
running under cygwin or something similar?
Yes, I am running cygwin.
Jun 27 '08 #58
On Tue, 03 Jun 2008 20:03:49 +0100, Jon Harrop <jo*@ffconsulta ncy.com>
wrote:
>You said ".NET is twice slower in four benchmarks: binarytrees, mandelbrot,
regexdna, sumcol.". I have already corrected two of your results (mandelbrot
and regexdna) and provided two more counter examples where .NET is >2x
faster than Java and explained why binarytrees is flawed.
Yes, you did correct two of them. I added recursive to the list, so
there are 3 more to go.

With FastMath, C# is not much faster in partialsums on my computer.
You haven't posted the other prime benchmark yet so I can't comment on
that.

Jun 27 '08 #59
On Tue, 3 Jun 2008 20:23:08 +0100, Jon Skeet [C# MVP]
<sk***@pobox.co mwrote:
>The mandelbrot one. Look back in the thread from where I first talked
about IO, and you'll see it's the last one referenced.
Yes, that was fixed by Harpo a while ago.
>Which benchmark are you talking about now? sum-file uses BufferedReader
but not StreamTokenizer as far as I can see.
I suspect System.in is already buffered by default.
>1) File IO
2) Conversion from binary to text
3) Splitting a stream of textual data into lines
4) Parsing text into integers
5) Integer addition
6) Writing the result to the console
(1), (2), (4), (5), (6) ?
Jun 27 '08 #60

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

Similar topics

80
3486
by: tech | last post by:
Hi, i have the following problem In file1.h namespace A { class Bar { void foo();
318
10906
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 ... http://kingrazi.blogspot.com/2008/05/shootout-c-net-vs-java-benchmarks.html Just to keep the post on topic for my friends at comp.lang.c++, how do I play default windows...
0
7876
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7804
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
5681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3832
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2307
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1409
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.