Hi. I recently ran a benchmark against two simple programs, one written in
Java and the other in C++. The both accomplish the same thing, outputting
"Hello World" on my screen. The C++ program took .5 seconds to complete on
my 400 Mhz PC while the Java program took 6.5 seconds.
I am running the SUSE 8.2 Linux distribution.
Why is Java that much slower than the C++ program? I read on Slashdot that
Java was almost as fast as C++. Here are my programs:
test.cpp
#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World";
}
test.java
public class test
{
public static void main(String[] args)
{
System.out.prin tln("Hello world");
}
}
The reason I ask is because I'm thinking of using Apache and Jakarta to do
some development. If Java cannot be speeded up, I will be forced to find
another alternative. 30 2816
"Mike Cox" <mi**********@y ahoo.com> wrote in message Hi. I recently ran a benchmark against two simple programs, one written
in Java and the other in C++. The both accomplish the same thing, outputting "Hello World" on my screen. The C++ program took .5 seconds to complete
on my 400 Mhz PC while the Java program took 6.5 seconds.
I am running the SUSE 8.2 Linux distribution.
Why is Java that much slower than the C++ program? I read on Slashdot
that Java was almost as fast as C++. Here are my programs:
test.cpp
#include <iostream> using namespace std; int main() { cout<<"Hello World"; }
test.java
public class test { public static void main(String[] args) { System.out.prin tln("Hello world"); } }
The reason I ask is because I'm thinking of using Apache and Jakarta to do some development. If Java cannot be speeded up, I will be forced to find another alternative.
Maybe it takes time to start up the Java engine, so it will appear to be
much slower for a very short program. Try a lenghthier test. Also, the
Java implementation makes a difference too.
Siemel Naran wrote: Maybe it takes time to start up the Java engine, so it will appear to be much slower for a very short program. Try a lenghthier test. Also, the Java implementation makes a difference too.
Would that be a concern when I use Jakarta to run a web application? Or
does Jakarta start up and never shut down the engine?
"Siemel Naran" <Si*********@RE MOVE.att.net> wrote in message
news:X4******** ***********@bgt nsc05-news.ops.worldn et.att.net... "Mike Cox" <mi**********@y ahoo.com> wrote in message
Hi. I recently ran a benchmark against two simple programs, one written in Java and the other in C++. The both accomplish the same thing,
outputting "Hello World" on my screen. The C++ program took .5 seconds to complete on my 400 Mhz PC while the Java program took 6.5 seconds.
I am running the SUSE 8.2 Linux distribution.
Why is Java that much slower than the C++ program? I read on Slashdot that Java was almost as fast as C++. Here are my programs:
On my machine (WIN XP) it takes at least 5 seconds to start
any program from a dos window that is not built into COMMAND.COM The reason I ask is because I'm thinking of using Apache and Jakarta to do some development. If Java cannot be speeded up, I will be forced to find another alternative.
Visual Basic is supported, I tried a "hello world" type program and it
took less than a second including the time to create the window.
Ann wrote: On my machine (WIN XP) it takes at least 5 seconds to start any program from a dos window that is not built into COMMAND.COM
Off topic, but Win XP doesn't even have command.com :)
"Arijit" <pa*****@yahoo. co.in> wrote in message
news:31******** *****@individua l.net... Ann wrote:
On my machine (WIN XP) it takes at least 5 seconds to start any program from a dos window that is not built into COMMAND.COM
Off topic, but Win XP doesn't even have command.com :)
--------- ya does ---------------
Volume in drive C has no label.
Volume Serial Number is 502A-848E
Directory of C:\WINDOWS\SYST EM32
08/29/2002 04:00 AM 50,620 COMMAND.COM
1 File(s) 50,620 bytes
0 Dir(s) 16,377,466,880 bytes free
Mike Cox wrote: I recently ran a benchmark against two simple programs, one written in Java and the other in C++. The both accomplish the same thing, outputting "Hello World" on my screen. The C++ program took .5 seconds to complete on my 400 Mhz PC while the Java program took 6.5 seconds.
I am running the SUSE 8.2 Linux distribution.
Why is Java that much slower than the C++ program?
Java programs are almost always almost as fast as C++ programs.
The problem with Java
(and other interpreted languages such as BASIC and MATLB)
is that it doesn't (can't) optimize certain [fine grain] operations
very well even if you compile the byte code into machine code.
This is very well documented in numerical programming.
I used Google http://www.google.com/
to search for
+"Java numerical programming"
and I found lots of stuff.
The bottom line is
You should *not* be afraid to write applications --
even high performance numerical applications --
in Java but be aware that you might run into difficulties
that you just can't work around without calling a routine
written in some other language such as C++.
I read on Slashdot that Java was almost [always] as fast as C++. Here are my programs:
cat test.cpp
#include <iostream>
int main(int argc, char* argv[]) {
std::cout << "Hello World" << std::endl;
return 0;
}
g++ -Wall -ansi -pedantic -o test test.cpp g++ --version
g++ (GCC) 3.4.1 time ./test
Hello World
0.003u 0.005s 0:00.00 0.0% 0+0k 0+0io 0pf+0w cat test.java
public class test {
public static void main(String[] args) {
System.out.prin tln("Hello world");
}
}
javac test.java which javac
/usr/java/j2sdk1.4.2_05/bin/javac time java test
Hello world
0.271u 0.042s 0:00.32 96.8% 0+0k 0+0io 1pf+0w cat /etc/fedora-release
Fedora Core release 2 (Tettnang)
Mike Cox wrote: Would that be a concern when I use Jakarta to run a web application? Or does Jakarta start up and never shut down the engine?
The startup time is only an issue for applications that either need to start
really fast or which only run for a short time (like your example). For any
reasonably long running program, the startup time is essentially irrelevant
(however irritating while debugging).
One thing to beware of, though, when considering Java in a server environment,
is that the startup time makes Java a very poor choice for writing pure CGI
programs. (But then I don't think CGI is such a wonderful idea anyway...)
Incidentally, the latest Sun JVM has some tweaks to reduce the minimum startup
time. I find them quite effective.
-- chris
"Mike Cox" <mi**********@y ahoo.com> wrote in message
news:31******** *****@individua l.net... Hi. I recently ran a benchmark against two simple programs, one written in Java and the other in C++. The both accomplish the same thing, outputting "Hello World" on my screen. The C++ program took .5 seconds to complete on my 400 Mhz PC while the Java program took 6.5 seconds.
I am running the SUSE 8.2 Linux distribution.
Why is Java that much slower than the C++ program? I read on Slashdot that Java was almost as fast as C++. Here are my programs:
test.cpp
#include <iostream> using namespace std; int main() { cout<<"Hello World"; }
test.java
public class test { public static void main(String[] args) { System.out.prin tln("Hello world"); } }
The reason I ask is because I'm thinking of using Apache and Jakarta to do some development. If Java cannot be speeded up, I will be forced to find another alternative.
Java takes time to initialise things, like preloading the classes, and lot
of other things. It's also an interpreted language, and it will be always
slower than compiled programs, no matter what you do. There is
native-compilers available if it really is a problem, and through JNI, you
can run native compiled code, if the need of speed is relevant.
But knowing those things, once running, a Java program, or at least a
consequent Java program which can be used for benchmarking purposes, can
compare in speed with C++ ones. The Jvm has had several optimisations that
made it quite good performance-wise to interpret Java code.
K This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: RobertMaas |
last post by:
After many years of using LISP, I'm taking a class in Java and finding
the two roughly comparable in some ways and very different in other
ways. Each has a decent size library of useful utilities as a standard
portable part of the core language, the LISP package, and the java.lang
package, respectively. Both have big integers, although only LISP has
rationals as far as I can tell. Because CL supports keyword arguments,
it has a wider range...
|
by: John Smith |
last post by:
Hello,
I have a rather odd question. My company is an all java/oracle shop.
We do everything is Java... no matter what it is... parsing of text
files, messaging, gui you name it. My question is this... is Perl so
much better at parsing text files and outputing that we would see a
substantial speed increase? We process about 10 million records in
flat files a day for reformatting before putting them in a DB.
Also, when it comes to...
|
by: Arich Chanachai |
last post by:
What are the pros and cons of Java?
How does Java measure up to .NET in terms of speed?
How about in terms of depth of classes?
I am looking for garbage collection while at the same looking for speed.
Java and .NET seem to be the only two application platforms offering
both, any suggestions?
Thanks all!!
|
by: Maurice LING |
last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic
typing, is there any other real reasons that Python is slower than Java?
maurice
|
by: DrUg13 |
last post by:
In java, this seems so easy. You need a new object
Object test = new Object() gives me exactly what I want.
could someone please help me understand the different ways to do the
same thing in C++. I find my self sometimes, trying
Object app = Object();
Object *app = Object();
Object app = new Object();
| |
by: Davey |
last post by:
Which is typically faster - a Java server application or a C++ server
application?
|
by: mearvk |
last post by:
Does C++ or C have something roughly equivalent to this:
http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html
What I need is a way to quickly convert between decimal and binary and
from char*/string to a numeric representation.
Thanks!
|
by: s0suk3 |
last post by:
Hello, I was hoping to get some opinions on a subject. I've been
programming Python for almost two years now. Recently I learned Perl,
but frankly I'm not very comfortable with it. Now I want to move on
two either Java or C++, but I'm not sure which. Which one do you think
is a softer transition for a Python programmer? Which one do you think
will educate me the best?
|
by: Sanny |
last post by:
I have an app in Java. It works fine. Some people say Java works as
fast as C. Is that true?
C can use assembly language programs. How much faster are they inplace
of calling general routines.
Can C++ directly acess the Registers.
Will the Computation 5-10 times faster than Java?
|
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...
|
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,...
| |
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,...
|
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...
|
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...
|
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();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |