Java vs C++ speed (IO & Sorting)

J

Jerry Coffin

[ ... ]
C:\>java -server WordCount bible2.txt>log.txt
Time: 5297 ms
C:\>java WordCount bible2.txt>log.txt
Time: 5421 ms
C:\>wc1 alice30.bible2>log2.txt
Time: 5750 ms

C++ loses to both java client and server with 40 meg bible2.txt.

From what you have above, it looks like you're comparing the time for
Java to count the bible vs. the time for C++ to count the Bible PLUS the
alice30 file.

When I run them both on just the bible, I get a time of 3136 ms for your
C++ code, and a time of 3860 ms for your Java code.
 
R

Razii

From what you have above, it looks like you're comparing the time for
Java to count the bible vs. the time for C++ to count the Bible PLUS the
alice30 file.

No, I wasn't doing that. I just mistyped it here. Actually, time for
this

C:\>wc1 alice30.bible2>log2.txt

will be 0ms since there is no such file called alice30.bible2

No such file exists.
 
J

Jerry Coffin

Is that Java server or slient?

Client -- when I try to use java -server, it tells me there's no server
VM.
And what happens when you try bible2.txt which is 10 bible text file
(40 meg?). Also, what happens when you run the test with WordCount.exe
(compiled by JET) found here

http://www.yousendit.com/transfer.php?action=download&ufid=519C866F2E2E2BA7

http://www.filecrunch.com/file/~3qxt7n

I tried to use JET, but it blew up with an error message saying I should
contact their customer support. You've never seemed particularly bright,
but if you think I'm going to download and run an executable from a
completely unknown source, you're even less intelligent than I realized.
 
L

Lew

Jerry said:
Client -- when I try to use java -server, it tells me there's no server
VM.

If you've been following this thread, you'll have found out that you need to
install some auxiliary JDK files into your Java installation, or simply use
the JDK version, which already has those auxiliary files installed.

This is, AFAIK, only true for Windows. It's not true for my Linux system.
 
J

Jerry Coffin

If you've been following this thread, you'll have found out that you need to
install some auxiliary JDK files into your Java installation, or simply use
the JDK version, which already has those auxiliary files installed.

This is, AFAIK, only true for Windows. It's not true for my Linux system.

I've been sort of following it, but only off and on. I did catch a bit
about installing auxiliary files, but unless the description was
unnecessarily complex, it sounded absolutely ridiculous to expect enough
customers to do it for the option to be worth any consideration at all.
 
R

Razii

Client -- when I try to use java -server, it tells me there's no server
VM.

Put the jdk\bin directory earlier in your path than system32. You fix
the path like this: right click my computer, click properties,
advanced, environment tab.
You've never seemed particularly bright,

That's coming from someone who can't even use his computer properly
but if you think I'm going to download and run an executable from a
completely unknown source, you're even less intelligent than I realized.

Never be too paranoid. Don't you have anti-virus software? In my
experience the most paranoid people on the Internet still have the
most spyware and junk.
 
R

Razii

I've been sort of following it, but only off and on. I did catch a bit
about installing auxiliary files, but unless the description was
unnecessarily complex,

Don't listen to nonsense. Your System32 directory has java.exe. Either
delete that or move JDK bin directory earlier in your path so windows
will find that one first.
 
R

Razii

Put the jdk\bin directory earlier in your path than system32. You fix
the path like this: right click my computer, click properties,
advanced, environment tab.

Also, if you follow that advice you will have to close and reopen
command prompt window for the new path to take effect.
 
L

Lew

Jerry said:
I did catch a bit
about installing auxiliary files, but unless the description was
unnecessarily complex, it sounded absolutely ridiculous to expect enough
customers to do it for the option to be worth any consideration at all.

Very many customers of Java products do, though, if they're running long-term
servers for example. Commercial enterprise Java products tend to include
suitable JVMs with the installation, often custom JVMs written by the vendor.

Many products do give customers a choice to install the correct JVM
distribution. For example, the Glassfish server offers a variety of bundles
with and without the JDK.

<http://java.sun.com/javaee/downloads/index.jsp>

It's not complex, because it uses an installer. You're right, one doesn't
expect the customer to handle moving around auxiliary files; one automates
that part of it.
 
R

Razii

It's not complex, because it uses an installer. You're right, one doesn't
expect the customer to handle moving around auxiliary files; one automates
that part of it.

For god's sake give up. You don't even have windows. There is nothing
complex here. There is Java.exe in System32 folder and there is one in
JDK/bin. All he needs to do is make sure that Windows finds java.exe
in JDK/bin BEFORE it fins the one in System32. Just fix the path.
 
R

Razii

When I run them both on just the bible, I get a time of 3136 ms for your
C++ code, and a time of 3860 ms for your Java code.

Can you post the times you get by including all three files in command
line, like this:

C:\>wc1 alice30.txt bible.txt bible2.txt>log.txt
Time: 6531 ms (c++)
C:\>java WordCount alice30.txt bible.txt bible2.txt>log.txt
Time: 6218 ms (java client)
C:\>java -server WordCount alice30.txt bible.txt bible2.txt>log.txt
Time: 5687 ms (java -server if you fixed the problem)

Also times varies, so post best of three...
 
J

Jerry Coffin

[ ... ]
That's coming from someone who can't even use his computer properly

Clearly you're as shortsighted, narrow-minded and...
Never be too paranoid. Don't you have anti-virus software? In my
experience the most paranoid people on the Internet still have the
most spyware and junk.

....mindbogglingly stupid as ever!
 
M

Mirek Fidler

First, time starts in main(). It's a short text file and if you
include VM load time, the test is invalid. The VM load time would be
longer than task itself. If not, use JET compiler so there is no VM
load time.

Also, how are you calling your page "Strings" when this supposed
benchmark spends 90% of the time in I/O reading and writing data to
disk? To reduce I/O factor, time counting ends before the output is
printed.

Thanks for the Java implementation. I will try to benchmark it soon.

As for I/O, I agree - I was benchmarking without the output too.

Mirek
 
R

Razii

As for I/O, I agree - I was benchmarking without the output too.

You need to fix your D program. It's doing the sorting at the output
time. How were you benchmarking without the output when c++ is already
sorted in map and you are sorting D at output time?

Also, the benchmark is invalid with such a small text file. How can
you say it's benchmark when time is 16ms in one run and 32 ms in the
next?

Use bible.txt (3 meg) and bible2.txt (40 meg, 10x bible)
 
R

Razii

Clearly you're as shortsighted, narrow-minded and...

If you can't take insults, don't insult others.
...mindbogglingly stupid as ever!

You are dumber than a stack of stones.

By the way, notice that this guy, Jerry Coffin, didn't post result
with 40x bible since he figured out that -server is faster than c++
version.

Also, interesting to see that none of c++ guru posted any time. I
guess that says it all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,198
Latest member
JaimieWan8

Latest Threads

Top