473,883 Members | 1,695 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 13269
Rudy Velthuis wrote:
Razii wrote:
>Consider what happens when you do a new/malloc: a) the allocator looks
for an empty slot of the right size, then returns you a pointer.

Modern allocators have several arrays of slots of suitable sizes, and
can therefore easily find one in the right size. The next allocation of
that size will also be immediately adjacent. Only rather large sizes
require another approach, but I assume these are pretty rare in both
kinds of environments, and I guess that programs tend to hang on to
such large objects much longer as well. Deallocation of objects is
immediate, which often means that memory consumption is lower and not
dependent on when a GC might finally run. Also, no heaps of memory are
moved around in non-GC memory management.

IOW, there are arguments for both approaches. The GC one has the big
advantage that one big cause of errors, all errors regarding memory
use, are more or less completely eliminated. But I doubt I would call
speed one of the main factors to choose a GC.
Actually GC speed is very good.

The problem people complain over is the non deterministic
aspect of it.

Arne
Jun 27 '08 #291
Jon Harrop wrote:
Arne Vajhøj wrote:
>Jon Harrop wrote:
>>Yes. I've no idea why they do that. Isn't buffered IO a better default?!
It is easier to put a buffered wrapper around an unbuffered stream
than the the other way around.

Did these languages not have optional arguments when their standard
libraries were designed?
Neither Java or C# has optional arguments today. But operator
overload can be used instead.

It is just not good OO to do it that way.

Arne

Jun 27 '08 #292
Jon Harrop wrote:
Lew wrote:
>Rudy Velthuis wrote:
>>Modern allocators have several arrays of slots of suitable sizes, and
can therefore easily find one in the right size. The next allocation of
that size will also be immediately adjacent. Only rather large sizes
require another approach, but I assume these are pretty rare in both
kinds of environments, and I guess that programs tend to hang on to
such large objects much longer as well. Deallocation of objects is
immediate, which often means that memory consumption is lower and not
dependent on when a GC might finally run. Also, no heaps of memory are
moved around in non-GC memory management.
Deallocation of young objects in Java takes no time at all...

You are ignoring all of the overheads of a GC, like thread synchronization ,
stack walking and limitations placed upon the code generator required to
keep the GC happy.
I would expect non-GC solutions to need more thread synchronization
than GC because it will need it many more times.
If you compare generically and assume infinite development time then
lower-level languages will surely win in terms of raw performance. The
reason the world moved on to GC'd languages is that they allow more
complicated programs to be written more robustly and efficiently in a given
amount of development time, i.e. they are more cost effective.
I agree with that part.

Arne
Jun 27 '08 #293
Razii wrote:
On Wed, 4 Jun 2008 19:49:20 +0100, Jon Skeet [C# MVP]
<sk***@pobox.co mwrote:
>into the search bar, you get 0.858272132, the same as the .NET answer.
That can't be pure coincidence, but I've no idea where the similarity
is...

That's pretty simple to explain. Both use hardware for angle reduction
and get the same wrong answer. That's why it's faster but wrong. It's
not just 1e15

What about these?

Console.WriteLi ne(Math.Sin (1e7));

0.4205477931907 71 (C# with .NET)
0.4205477931907 824912985065897 4095 (right answer)

Console.WriteLi ne(Math.Sin (1e10));

-0.4875060250762 7 (C# with .NET)
-0.4875060250875 106915277942943 4811 (right answer)

I am sure there are better examples but the point is made.
Everybody knows there is this effect. Maybe everybody except Jon H.

But does it matter ?

I don't think there will be that many usages where the differences in
accuracy between the Java way and the C# way will have much impact.

Either it will be good enough or even greater precision will be needed.

Arne
Jun 27 '08 #294
Jon Harrop wrote:
Razii wrote:
>On Wed, 4 Jun 2008 20:01:54 +0100, Jon Skeet [C# MVP]
<sk***@pobox.c omwrote:
>>Out of interest, what happens in your version of the test if you avoid
the deprecated StreamTokenizer Constructor? Force Java to actually deal
with text as text (which is why the constructor taking Stream is
deprecated) and see how the results fare.
$ time cat sum.txt | java -server sumcol (deprecated)
10500000

real 0m4.224s
user 0m0.155s
sys 0m0.327s

$ time cat sum.txt | sumcol (.NET)
10500000

real 0m6.395s
user 0m0.077s
sys 0m0.342s

changing the line to

StreamTokenize r lineTokenizer = new StreamTokenizer (new BufferedReader
(new InputStreamRead er(System.in))) ;

$ time cat sum.txt | java -server sumcol
10500000

real 0m5.375s
user 0m0.202s
sys 0m0.296s

still faster.

You are still timing Cygwin's implementation of Unix pipes which has nothing
to do with anything.
Do you believe that by there is a little test in the Cygwin code that
makes it work slower if it sees a .NET code ? Or why do you think the
Cygwin stuff can explain the difference in the two tests ?

Arne
Jun 27 '08 #295
Jon Harrop wrote:
Razii wrote:
>On Wed, 04 Jun 2008 19:31:43 +0100, Jon Harrop <jo*@ffconsulta ncy.com>
wrote:
>>64-bit or 32-bit Windows?
32-bit. I hope your next answer is not that 32-bit is legacy system.

So you're running a 64-bit CPU in 32-bit mode.
That is what most people do.

32 bit Windows on a 64 bit capable Intel or AMD CPU.

And therefore obviously what is most relevant to test.

Arne
Jun 27 '08 #296
Patricia Shanahan wrote:
Arguable in the case of Java. The Java Language Specification says that
each compilation unit implicitly starts with an import of "the
predefined package java.lang".

I don't know whether C# has any libraries with such a privileged position.
There is no implicit import of namespace System.

But I am not sure that I consider that a big difference.

Both Java and C# are pretty married to their libraries anyway.

Arne
Jun 27 '08 #297
Jon Harrop wrote:
Razii wrote:
>On Wed, 04 Jun 2008 20:34:59 +0100, Jon Harrop <jo*@ffconsulta ncy.com>
wrote:
>>You are still timing Cygwin's implementation of Unix pipes which has
nothing to do with anything.
I am still waiting for you to verify and demonstrate it has any
effect.

Your inexplicably anomalous results already proved that.
For anyone with just a minimum of understanding of logic: not.

Arne
Jun 27 '08 #298
Mark Thornton wrote:
Jon Skeet [C# MVP] wrote:
>The VM spec is also separate from the language spec, which is a good
thing. It's just a shame that the name "Java" applies to the platform,
the runtime, and the language.
And at times several other things with no obvious relationship at the
whim of Sun's marketing department.
I guess you can argue that funding Java development and giving most
of it away for free has given them the right to try and make a few
bucks selling a Java branded Linux.

Arne
Jun 27 '08 #299
Jon Skeet [C# MVP] wrote:
Razii <ni*********@ma il.comwrote:
>As for C# using file, post the changes.

I did, early yesterday evening.
Some people has an amazing ability to miss the posts
which does not fit their pet theory.

Arne
Jun 27 '08 #300

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

Similar topics

80
3572
by: tech | last post by:
Hi, i have the following problem In file1.h namespace A { class Bar { void foo();
318
11198
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 sounds with C++?
0
9935
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9791
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11137
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10844
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9571
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7122
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5990
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4215
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3231
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.