b*******9 发帖数: 15 | 1 Hi,
I rewrote a c++ program to java program. Both syntax and results are the
same. But java program is very slow. c++ is 40 seconds, but java is 800
seconds. Does anyone know the problem and how to improve my java program?
Thanks.
Bejamin |
e***e 发帖数: 351 | 2 Post your code here, maybe ppl can tell
【在 b*******9 的大作中提到】 : Hi, : I rewrote a c++ program to java program. Both syntax and results are the : same. But java program is very slow. c++ is 40 seconds, but java is 800 : seconds. Does anyone know the problem and how to improve my java program? : Thanks. : Bejamin
|
b*******9 发帖数: 15 | 3 Thank emote's reply. But the code is too long to post here.I hopt to get
common ideas like environment, compiling and runing options to improve speed.
【在 e***e 的大作中提到】 : Post your code here, maybe ppl can tell
|
j******o 发帖数: 82 | 4 What type of program is that?
How did you make the conversion?
What kind of hardware/OS?
Do you have a lot of I/O access?
【在 b*******9 的大作中提到】 : Hi, : I rewrote a c++ program to java program. Both syntax and results are the : same. But java program is very slow. c++ is 40 seconds, but java is 800 : seconds. Does anyone know the problem and how to improve my java program? : Thanks. : Bejamin
|
b*******9 发帖数: 15 | 5 Thanks, Jojomojo.
his program reads a 压缩 file, then 解压 it.
Only change is to change c++ point to java array. Put many c++ classes and
method to one java class and one method (does this cause speed problem?).
Run on Linux.
【在 j******o 的大作中提到】 : What type of program is that? : How did you make the conversion? : What kind of hardware/OS? : Do you have a lot of I/O access?
|
m******t 发帖数: 2416 | 6
All the copying between I/O buffers is probably killing it.
Try map the files into memory.
【在 b*******9 的大作中提到】 : Thanks, Jojomojo. : his program reads a 压缩 file, then 解压 it. : Only change is to change c++ point to java array. Put many c++ classes and : method to one java class and one method (does this cause speed problem?). : Run on Linux.
|
A**o 发帖数: 1550 | 7 and the overhead in array operations as well...
again, no code, hard to say
【在 m******t 的大作中提到】 : : All the copying between I/O buffers is probably killing it. : Try map the files into memory.
|
r*d 发帖数: 896 | 8 可能是由于JVM吧。
【在 b*******9 的大作中提到】 : Hi, : I rewrote a c++ program to java program. Both syntax and results are the : same. But java program is very slow. c++ is 40 seconds, but java is 800 : seconds. Does anyone know the problem and how to improve my java program? : Thanks. : Bejamin
|
o*******a 发帖数: 46 | 9 profiler the program and find out where is the bottom neck.
【在 b*******9 的大作中提到】 : Hi, : I rewrote a c++ program to java program. Both syntax and results are the : same. But java program is very slow. c++ is 40 seconds, but java is 800 : seconds. Does anyone know the problem and how to improve my java program? : Thanks. : Bejamin
|
r*****l 发帖数: 2859 | 10 Performance is not Java's strong point. I would be surprise
if you say Java is faster than C/C++.
【在 b*******9 的大作中提到】 : Hi, : I rewrote a c++ program to java program. Both syntax and results are the : same. But java program is very slow. c++ is 40 seconds, but java is 800 : seconds. Does anyone know the problem and how to improve my java program? : Thanks. : Bejamin
|
k***r 发帖数: 4260 | 11 JVM startup time is way longer. You would want to take that into account.
Java in general is slower but shouldn't be that slow. |