Redian新闻
>
Why My Java Program Is So Slow?
avatar
Why My Java Program Is So Slow?# Java - 爪哇娇娃
b*9
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
avatar
e*e
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

avatar
b*9
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
avatar
j*o
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

avatar
b*9
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?

avatar
m*t
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.

avatar
A*o
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.

avatar
r*d
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

avatar
o*a
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

avatar
r*l
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

avatar
k*r
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.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。