You are not logged in.

#1 2005-12-08 18:15:32

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

helloworld comparisson (split from: Jacman)

dusty:~ $ time java test
Hello world

real    0m0.099s
user    0m0.028s
sys     0m0.016s

That's hardly a noticeable startup time. AFAIK, the entire JRE has to start up even for a simple hello world.

On the other hand, this is substantialy slower then hello world python:

dusty:~ $ time python test.py 
hello world

real    0m0.014s
user    0m0.012s
sys     0m0.000s

Even so, I tihnk the argument that the JRE startup time is slow is simply false.

Now the thing people will say is "but look how long <limewire/azureus/netbeans/eclipse/your least favourite java app> takes to load".  However, all of these are complex applications. Look how long any dev environment takes to load and compare to netbeans.... not eclipse, eclipse has something wrong with it. I think it tries to load your entire hard disk into memory before it runs or something, but that's not Java's fault... Or compare firefox, which is also a C-based app. It loads a lot faster since 1.5, but still a delay. I'm sure a Java web browser would not take all that much longer.

Java programs are fine when running. They're just not much fun to code.... ;-)

Dusty

Offline

#2 2005-12-08 18:31:36

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: helloworld comparisson (split from: Jacman)

griff@animus:~$ gcc hello.c -o hello
griff@animus:~$ time ./hello 
hello world

real    0m0.002s
user    0m0.000s
sys     0m0.000s

hehe

Offline

#3 2005-12-08 20:01:20

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: helloworld comparisson (split from: Jacman)

good point, that. ;-)

Offline

#4 2005-12-09 02:39:18

xerxes2
Member
From: Malmoe, Sweden
Registered: 2004-04-23
Posts: 1,249
Website

Re: helloworld comparisson (split from: Jacman)

phrakture wrote:
griff@animus:~$ gcc hello.c -o hello
griff@animus:~$ time ./hello 
hello world

real    0m0.002s
user    0m0.000s
sys     0m0.000s

hehe

hmm, nice you used c phrak. i mean, we all know how slow c++ is, no??!!! tongue


arch + gentoo + initng + python = enlisy

Offline

#5 2005-12-09 07:44:24

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,751

Re: helloworld comparisson (split from: Jacman)

emmm

time ./helloworld.rb 
hello world
real    0m0.006s
user    0m0.004s
sys     0m0.004s

Mr Green

Offline

#6 2005-12-09 16:18:26

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: helloworld comparisson (split from: Jacman)

xerxes2 wrote:

hmm, nice you used c phrak. i mean, we all know how slow c++ is, no??!!! tongue

On a totally different (crappier) machine:

$ time ./hello_cpp && time ./hello_c
hello world

real    0m0.080s
user    0m0.010s
sys     0m0.050s
hello world

real    0m0.100s
user    0m0.020s
sys     0m0.050s

So, umm... I win?

(Sorry arooaroo, I'll split this now)

Offline

#7 2005-12-09 16:33:34

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: helloworld comparisson (split from: Jacman)

And if I keep doing this in quick succession, it gets to here:

$ time ./hello_cpp && time ./hello_c
hello world

real    0m0.070s
user    0m0.020s
sys     0m0.020s
hello world

real    0m0.070s
user    0m0.020s
sys     0m0.030s

Which is the closest C comes to winning.  However, I must point out:

$ gcc --version
gcc.exe (GCC) 3.2.3 (mingw special 20030504-1)

Offline

#8 2005-12-09 16:37:07

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,751

Re: helloworld comparisson (split from: Jacman)

errr bash lol

 time ./hello.sh 
hello world

real    0m0.006s
user    0m0.004s
sys     0m0.000s

Mr Green

Offline

#9 2005-12-09 16:38:05

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: helloworld comparisson (split from: Jacman)

Hah, your bash is faster than ruby!

Offline

#10 2005-12-09 16:42:42

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: helloworld comparisson (split from: Jacman)

ok, take a look at these timings a little closer.

All of them fire up in less than a tenth of a second. For all intents and purposes, this is instantaneous as far as response to the user goes, right?

My original post was to show that the JVM does *not* take a long time to start. Sub-decisecond comparisons are not useful in terms of response time to the end user.

Of course, there are other timings we could compare, like time it takes to write the program. For example, hello world in python took me about 1 second to type Hello world in Java took about ten seconds, and then I had to compile it. I'd say ruby would be similar to python (one line), while bothe C and C++ would take about as long as Java. On this order, I saved 9 seconds typing in python. You'd have to run your optimized C/C++ code a lot of times to regain those nine seconds in terms of running execution.

Dusty

Offline

#11 2005-12-09 16:47:14

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,751

Re: helloworld comparisson (split from: Jacman)

phrakture wrote:

Hah, your bash is faster than ruby!

but of course its not doing any work lol

/me reads Dustys post....

phrakky how many lines of C are there in *your* code ?


Mr Green

Offline

#12 2005-12-09 17:00:50

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: helloworld comparisson (split from: Jacman)

Dusty wrote:

Of course, there are other timings we could compare, like time it takes to write the program. For example, hello world in python took me about 1 second to type Hello world in Java took about ten seconds, and then I had to compile it. I'd say ruby would be similar to python (one line), while bothe C and C++ would take about as long as Java. On this order, I saved 9 seconds typing in python. You'd have to run your optimized C/C++ code a lot of times to regain those nine seconds in terms of running execution.

I have vim spam out a skeleton when I edit a non-exiting c or cpp file... they spit out:

#include <stdio.h>
int main()
{
}

and

#include <iostream>
int main()
{
}

So my net result is 1 line of either printf("hello worldn"); or std::cout << "hello world" << std::endl;

Coding time argument negated!

Offline

#13 2005-12-09 17:49:21

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: helloworld comparisson (split from: Jacman)

hmmm.... what about time it takes to set up such templates etc? ;-)

Dusty

Offline

#14 2005-12-09 17:55:28

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,615
Website

Re: helloworld comparisson (split from: Jacman)

Some things to think about with regard to startup times:
How much of the JVM was resident in memory before your test invocation?
Did you run the test after a fresh boot?

Also, I *thought* that the Java VM only loaded certain classes and objects *as needed* to a certain extent. I think it does prefetch some more common things, like certain I/O, some general frameworks, and things like that...

I long ago realized that for *some things*, java is not the slowest of the slow. I really do hate java GUI stuff though..that is, and has always been, fairly slow.

But for raw processing, java isn't too bad. I know lots of crypto engines that are written in java first AES, aka modified rijndael, was first written in java for instance.

Java is an integral part of Globus clustering as well.

I just dont like it myself anymore.. I *actually* possess that rare ability to seperate myself from my biases to a certain extent though. Or at least realize enough about my own biases, so I make sure to make concessions for them when I speak about things in which my biases may be effected.
wink


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#15 2005-12-09 19:05:12

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: helloworld comparisson (split from: Jacman)

Dusty wrote:

hmmm.... what about time it takes to set up such templates etc? ;-)

~/.vim/templates/cpp

#include <iostream>

int main()
{
}

~/.vimrc

au BufNew *.cpp 0read ~/.vim/templates/cpp

probably the same amount of time as it takes to do "pacman -S python" and wait for it to install.

Offline

#16 2005-12-09 19:37:05

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,751

Re: helloworld comparisson (split from: Jacman)

Slight Hack &

 time ./helloworld.rb 
hello world

real    0m0.006s
user    0m0.004s
sys     0m0.000s

Templates for two lines of code :shock:


Mr Green

Offline

Board footer

Powered by FluxBB