A
asterisc
No, is it's not in STL
So you compare STL vs Java library!
I agree that Java library is also larger. Java can create Applets as
well.
Do we care? I don't think so!
No, is it's not in STL
Razii said:We have reached the conclusion! You can write a program in Java that
can be as fast as anything. This benchmark is on U++ home page as an
example of U++ especially optimized non:std String and map. And Mirek
Fidler asked me to write one in Java (no matter how I do it or what
method I use) that can be faster than U++.. Well, I got some help from
pmk and the debate is over. Java can be faster than U++ )> [...]
Yep, this version is good enough for even large data:http://www.pastebin.ca/975248
Each file 80 mb
C:\>WCUPP bible3.txt bible3.txt bible3.txt
Time: 4984 ms
C:\>Wc_pmk bible3.txt bible3.txt bible3.txt
pmk time 3469ms
C:\>WCUPP bible3.txt bible3.txt bible3.txt bible3.txt bible3.txt
bible3.xt
Time: 8343 ms
C:\>Wc_pmk bible3.txt bible3.txt bible3.txt bible3.txt bible3.txt
bible3.xt
pmk time 5687ms
java version way faster than UPP
Well, if you run it once the file would be already be in cache for the
second test. Even in the UPP version (and all previous times cited), I
was not including the time for first run (which would obviously be
slower first time if there is HDD activity).
If the HDD access time is included, then probably the following
version would be faster since it maps the file.
http://www.pastebin.ca/976637
g++ -O2 -fomit-frame-pointer "wc2.cpp" -o "wc2.exe"
(40 MB)
youth, 701
youthful, 11
youths, 20
zeal, 144
zealous, 84
zealously, 22
Time: 3468ms
the count is still wrong. There are 20 "zealously" in 10x bible.txt,
not 22 .. all other numbers are wrong too.
g++ -O2 -fomit-frame-pointer "wc2.cpp" -o "wc2.exe"
(40 MB)
youth, 701
youthful, 11
youths, 20
zeal, 144
zealous, 84
zealously, 22
Time: 3468ms
the count is still wrong. There are 20 "zealously" in 10x bible.txt,
not 22 .. all other numbers are wrong too.
mine is..
C:\>g++ -v
gcc version 4.3.0 (GCC TDM-2 for MinGW)
This topic was on these newsgroups 7 years ago
http://groups.google.com/group/comp.lang.c++/msg/695ebf877e25b287
I said then: "How about reading the whole Bible, sorting by lines, and
writing the sorted book to a file?"
Who remember that from 7 years ago, one of the longest thread on this
newsgroup
You said you don't have Java JDK, but you must have JVM, right?
Everyone does. Here is the Jwc.class file (only 3 KB)
http://www.yousendit.com/transfer.php?action=download&ufid=9808989058...
command line: java Jwc bible.txt
and here is compiled with JET version (Jwc.exe along with Jet rt)
http://www.yousendit.com/transfer.php?action=download&ufid=5E12D0060E...
Well, in some cases VC++ was also slower; that's why I was using g++
in any case, with VC++ I get
yours, 50
yourselves, 1900
youth, 700
youthful, 10
youths, 20
zeal, 140
zealous, 80
zealously, 20
Time: 2671ms
Weird that g++ gives different results. I thought C++ was very
portable. What happened?
printf( "Time: %ld ms\n", (end - start) / CLOCKS_PER_SEC * 1000 );
I changed it back to
std::cout <<"Time: " << double(end-start)/CLOCKS_PER_SEC * 1000 << "
ms\n";
zealous, 80
zealously, 20
Time: 1171 ms
This version doesn't even compile with g++ (MinGW).
I'm sorry about that. The printf was wrong, it should have been
something like: %.0f.. and (float) in front of every number.
However, I have reproduced your algorithm in C++.
I have better results than the Java version. I tried it on two
marchines and it seems faster!
Altought is not correct (it puts lowercase in front of uppercase,
which is not ok) it behaves exactly like the Java version. Same
output, same algorithm, only a bit faster.
Here is the link:http://pastebin.com/m1c5271bf
Try it and post the results on your machine.
I don't care about MinGW compiler. I compiled it successfull on both VC
++ 2003 on winXP and GCC 4.1.2 p1.0.2 on my Gentoo machine.
Regards,
Good job )
I don't have better result than Jet version. I get about the same
result.
30 Zuph
50 Zur
10 Zuriel-
50 Zurishadda
10 Zuzims-
Time: 625ms
That's ~ same as Jet (but Jet was slightly faster)
It's easy to fix upper and lower case ... just remove ^32 .. see this
versionhttp://www.pastebin.ca/977458that sorts with lower cases
first.
Just as in the case of U++, it has special optimized Strings.
The same is true the other way. This trie algorithm was initially
posted by Brettschneider as C++ version.. I converted it to Java )
Nice trick, huh?
However, the structure was improved into one array by pmk. That's what
made it beat U++.
What do you mean "has optimized Strings". Right now, there is no
string at all. I use only char *.
U++ has optimized strings. You don't.
Please post times for this version as well as for your latest jet
thing. I'm curious which one is the faster.
Time: 593ms ~ same as java version compiled with JET.
And please compile it using optimizations! (-O3 -fomit-frame-pointer
on GCC, if it works), or (-Ox [full-optimizations] on VC++).
doesn't compile with g++
wc2.cpp: In function 'int main(int, char**)':
wc2.cpp:37: error: 'malloc' was not declared in this scope
wc2.cpp:87: error: 'free' was not declared in this scope
Right now I got better times on two machines ( 440ms c++ vs. 550ms
java.. (that was before updating) )
And in this time, I don't wait for any JVM to get loaded.
Ae you using Jet version or JVM version? Jet compiled version is ~100
ms faster than JVM. You can get Jet here
http://www.excelsior-usa.com/jetdlbeta.html
So that's faster than Jet. You said that 590ms was about the same asThat worked. Time: 562ms on g++
Depends on what are you working on.but the common claim in this newsgroup is that c++ is way faster. How
many threads we had? In most cases, the difference was really small.
Never heard of U++ before, but if it's C/C++ standard compliance, itIn any case, U++ version was beaten -- both by C++ and Java. Next
project.
It looked like you were starting a flame, but constructive discussionsI will add your version. I posted it to the blog to get some responses
here on this newsgroup.
Would Mirek Fidler add this to the site now? I doubt it
Nothing happens with the loop. I am not creating new objects just
reading same chars over and over and incrementing the count. Why would
loop make any difference? I added the loop of 20
C:\>java -server Jwc2 bible2.txt
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.