473,883 Members | 1,576 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 13276
Razii wrote:
On Thu, 05 Jun 2008 18:54:02 +0100, Jon Harrop <jo*@ffconsulta ncy.com>
wrote:
>>$ time java -server -Xms64m binarytrees 20 (Java)
...
real 0m36.328s
user 0m0.031s
sys 0m0.046s

This takes 69s here.

On my comp that takes 32 seconds. However, it's possible to double the
speed again by using these flags:

$ time java -server -Xms512m -Xmx512m -XX:NewRatio=1 binarytrees 20

stretch tree of depth 21 check: -1
2097152 trees of depth 4 check: -2097152
524288 trees of depth 6 check: -524288
131072 trees of depth 8 check: -131072
32768 trees of depth 10 check: -32768
8192 trees of depth 12 check: -8192
2048 trees of depth 14 check: -2048
512 trees of depth 16 check: -512
128 trees of depth 18 check: -128
32 trees of depth 20 check: -32
long lived tree of depth 20 check: -1

real 0m16.955s
user 0m0.015s
sys 0m0.015s

that's now 3.4 times faster than C# and F#.
As I said before, this benchmark is completely flawed and we can carry on
optimizing forever.

Here is another F# implementation that is much faster than your Java
(again):

#light

#I @"C:\Program Files\Reference Assemblies\Micr osoft\Framework \v3.5"
#r @"C:\Program Files\Microsoft Parallel Extensions Jun08
CTP\System.Thre ading.dll"

[<CompilationRep resentation(Com pilationReprese ntationFlags.Pe rmitNull)>]
type 'a tree = Empty | Node of 'a tree * 'a * 'a tree

let inline make0 i = Node(Empty, i, Empty)

let inline make1 i =
let t = make0 (2*i)
Node(t, i, t)

let inline make2 i =
Node(make1 (2*i - 1), i, make1 (2*i))

let rec make_aux i = function
| 2 -make2 i
| d -Node(make_aux (2*i - 1) (d-1), i, make_aux (2*i) (d-1))

let make i = function
| 0 -make0 i
| 1 -make1 i
| d -make_aux i d

let rec check = function
| Empty -0
| Node(l, i, r) -i + check l - check r

let min_depth = 4
let max_depth =
let n = try int Sys.argv.[1] with _ -20
max (min_depth + 2) n
let stretch_depth = max_depth + 1

let loop_depth d () =
let niter = 1 <<< (max_depth - d + min_depth)
let mutable c = 0
for i = 1 to niter do
c <- c + check(make i d) + check(make (-i) d)
niter, d, c

let main() =
let c = check (make 0 stretch_depth)
Printf.printf "stretch tree of depth %i\t check: %i\n" stretch_depth c
let long_lived_tree = make 0 max_depth
let futures =
[ for d in min_depth .. 2 .. max_depth ->
System.Threadin g.Tasks.Future. Create(loop_dep th d) ]
for future in futures do
let niter, d, c = future.Value
printf "%i\t trees of depth %i\t check: %i\n" (2 * niter) d c
Printf.printf "long lived tree of depth %i\t check: %i\n"
max_depth (check long_lived_tree )

do
let t = new System.Diagnost ics.Stopwatch()
t.Start()
main()
printf "%d\n" t.ElapsedMillis econds

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
Jun 27 '08 #241
Razii wrote:
On Fri, 06 Jun 2008 01:54:46 +0100, Jon Harrop <jo*@ffconsulta ncy.com>
wrote:
>>This is now 2x faster than Java again but the benchmark is flawed so we
can keep doing this forever.

It's not. Your version is exactly same speed as C# (in fact slightly
slower): 0m28.575s. (I was getting 25.38 with C#).

Skeet also got same numbers as me, basically .NET is 1.6 to 2 two
times slower.
You are obviously not using the optimized code that I just posted.

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
Jun 27 '08 #242
On Jun 6, 12:48 am, Barry Kelly <barry.j.ke...@ gmail.comwrote:
Jon Skeet wrote:
Barry Kelly <barry.j.ke...@ gmail.comwrote:
2) Usually, when running "for real" and not for test, only a single
implementation of that method will be loaded into the runtime.
Absolutely. I don't dispute that at all - I just wonder how often those
virtual methods are both small enough to be inlined *and* critical for
performance.

I was more focusing on the ability of the JVM to optimize a dynamic
dispatch to a static dispatch, rather than virtual method inlining per
se.
Good point. I'd been completely ignoring the cost of the vtable
lookup.
Both can be relevant, but I think the first is more important (certainly
for Java code) than the second; but the first also has applications more
generally to IoC etc.
Right. It would be very interesting to get stats (for various
applications - it's no doubt *highly* sensitive to what application
you're running) on:
1) What proportion of method calls are theoretically virtual in Java
2) What proportion of method calls are *actually* executed virtually
in Java
3) What proportion of method calls are virtual in .NET

Jon
Jun 27 '08 #243
On May 31, 6:28 am, King Raz <klgfgfgj...@ma il.comwrote:
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...java-benchmark...

Just to keep the post on topic for my friends at comp.lang.c++, how do
I play default windows sounds with C++?
C++ standards don't mention any 'sound' concept. Try trolling some
platform specific groups!
Jun 27 '08 #244
Jon Skeet [C# MVP] wrote:
Jon Harrop <jo*@ffconsulta ncy.comwrote:
I'll try to find more GC settings - a quick look at Perfmon suggests
it's spending most of its time there. It could well be that Java's GC
is better for this test scenario.

The command line options that Razii chose effectively turn off the GC.

No they don't. They allocate a fixed sized heap (512M), one with a an
equal size of old/new spaces, but one which is still garbage collected.
The number of garbage collections plummets.

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
Jun 27 '08 #245
On Fri, 6 Jun 2008 04:04:38 -0700 (PDT), asterisc <Ra*******@ni.c om>
wrote:
>C++ standards don't mention any 'sound' concept. Try trolling some
platform specific groups!
He is the only one who fell into the trap and responded :)

How do I use GCC on Windows?

Let's if he responds again.

Jun 27 '08 #246
On Fri, 06 Jun 2008 13:44:50 +0100, Jon Harrop <jo*@ffconsulta ncy.com>
wrote:
>The number of garbage collections plummets.
Yes, there are less garbage collections calls (that was the tweak
obviously) but all garbage is collected.
Jun 27 '08 #247
Razii wrote:
How do I use GCC on Windows?
Similar to other platforms.

Arne
Jun 27 '08 #248
Jon Harrop <jo*@ffconsulta ncy.comwrote:
Please go by what he posted, not some other settings you've come up
with. Your claim that Razii "effectivel y turn[ed] off the GC" is simply
untrue.

My claim was clearly perfectly correct.
Rubbish. You claimed that Razii had turned the garbage collector off.
He certainly hadn't, or the program would not have run to completion,
limited as it was by his options to 512MB.

Just to make it absolutely clear, here is how Razii was running the
code:

java -server -verbose:gc -Xms512m -Xmx512m -XX:NewRatio=1

With those options, the garbage collector *does* run, and *does*
collect memory. Your claim was absolutely incorrect, and your attempt
to confuse the matter by posting other options which *did* negate the
need for the garbage collector to run does not in any way change the
options under which Razii ran his test.
Please follow this logic and explain how your logic could *possibly* be
correct:
1) The test creates 305135616 instances of TreeNode. To verify this,
just introduce a static counter which is incremented in the
constructor, and print out the result at the end of the test.

2) The option -Xmx512m limits the heap to 512MB

3) There is no way of holding 305135616 objects in memory at the same
time in Java within 512MB. (An object would have to take less than
1.759 bytes on average, which is clearly ridicuolous.)

4) Therefore the memory used by some of the objects must have been
reused by other objects. The mechanism for this is garbage collection.

5) Therefore the GC had *not* been "effectivel y turned off".
Now rather than just repeatedly stating your claim, or arguing by using
*different* options, please address the steps above. Which of the 5
facts/deductions above do you disagree with? The conclusion directly
contradicts your claim, so you should either retract your claim or
refute the logic above.

--
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 #249
On Sat, 7 Jun 2008 13:29:53 +0100, Jon Skeet [C# MVP]
<sk***@pobox.co mwrote:
>Now rather than just repeatedly stating your claim, or arguing by using
*different* option
He not only used diiferent options (3 gig ram) but he also reduced
command line argument from 20 to 16.

Jun 27 '08 #250

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
9936
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
10742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10845
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
10412
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7970
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5990
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4609
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
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.