aspose file tools*
The moose likes Performance and the fly likes Another JAVA vs .NET Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "Another JAVA vs .NET" Watch "Another JAVA vs .NET" New topic
Author

Another JAVA vs .NET

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

After reading the JAVA Pet Store Post in this forum, I had e-mailed an associate the links arguing both sides of JAVA and .NET. My associate is a .NET fanatic as I am a JAVA fanatic. He decided to challenge me. He wrote a program that calls an empty function 500 million times using VB.NET and it took 6 seconds from start to finish. He then wanted me to do the same thing in JAVA, so I did. 2.6 seconds. HA.
We are both running Dell GX240 1.7 GHz 256MB RAM with Windows XP. Below is his code and my code. I challenge anyone else to do the same thing and see what the results are.
The reason I find this so interesting is that these programs are so simple and so basic, I honestly thought that a BINARY program would out do a BYTECODE program.
VB.NET

JAVA

[ June 13, 2002: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
Just for kicks I wrote this in C. It took about 18 secs. In Java, 6 (7 when I commented out the method call...). So I went back to C and removed the method call, and low and behold a little less than 6 seconds.
Then in C with the call and -O3 -- less than 3 seconds.
In Java with -O -- 5
The moral/bad news: the speed of something like this seems to be a function of how much compiler optimizing is done by default, not of instruction execution speed. Since you will rarely be calling empty functions over and over, this particular difference doesn't seem significant.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
This isn't news so I'm moving it to Java performance.
in my opinion the results are the product of the optimizer compiler more than anything else.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

How is that bad news? I am in no way saying that JAVA is faster than .NET by our little test. I especially would never say it is faster than C. I was saying that in this instance, it is faster.
And I agree that it has a lot to do with compiler optimization, but isn't that part of it? I mean, if it is a compiler optimization issue, then we could deduce that JAVA has a better "shipped with" compiler than .NET? I am not stating that as fact, but that could be deduced.
I would like to see the C code you wrote and would like to know what compiler you used for C. I always use the GNU compiler on a Linux platform. I am going to write my own tonight and see if I get similar results.
I hope I get to see others results regarding this issue. Also include the computer specs you are doing this experiment with.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

AMD Athlon 950, 256MB (133MHz) RAM, and Windows 98
5 seconds
Jamie
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
I confess I don't actually know how to time stuff in C, so I did it roughly by stopwatch. Gcc for cygwin on Windows 98 (about 5-600 MHz I think + 128 megs RAM).

I assume that any production build of software will turn on whatever optimizations are applicable. I suppose I assume too much . I don't know what the VB.NET optimizer can do when you let it take control. Maybe you should try an optimized comparison.
Igor Ko
Ranch Hand

Joined: Jun 24, 2002
Posts: 90
Why you don't check delta time like:
long start = System.currentTimeMillis();
long deltaTimeMs = System.currentTimeMillis() - start;
It looks much more simple.
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

Actually Java is not running bytecodes. Only the first pass after which the JIT or the new version of that will take over and you will be executing maching code.
Try it with the JIT on vs. Off. (or whatever the JIT is called these days)
 
 
subject: Another JAVA vs .NET