Redian新闻
>
code Re: structure in Java??
avatar
code Re: structure in Java??# Java - 爪哇娇娃
s*M
1
obvious things can often be wrong though.
here is one of tests i coded. certainly, this is an over simplistic operation
but it does tell sth.
try to run with a counter sesnsible large so that it takes seconds. 10^8~9
should be ok.
public class Test{

public static void main(String[] args){
System.out.println("starting...");
long re=0;
long start = System.currentTimeMillis();
int count=Integer.valueOf(args[0]).intValue();
for(int i=0; ire = re+i;
}
long dur = System.currentTim
avatar
st
2
your java program:
time passed: 3891 for your program, I set count to 10^9
compare to a small c++ program under vs.net 2003. time passed:844
#include "stdafx.h"
#include "windows.h"
int _tmain(int argc, _TCHAR* argv[])
{
printf("starting...");
long re=0;
long start = GetTickCount();
int count=1000000000;//Integer.valueOf(args[0]).intValue();
for(int i=0; ire = re+i;
}
long dur = GetTickCount() - start;
p

【在 s******M 的大作中提到】
: obvious things can often be wrong though.
: here is one of tests i coded. certainly, this is an over simplistic operation
: but it does tell sth.
: try to run with a counter sesnsible large so that it takes seconds. 10^8~9
: should be ok.
: public class Test{
:
: public static void main(String[] args){
: System.out.println("starting...");
: long re=0;

avatar
e*g
3
why do you comment out the most expensive part?

【在 st 的大作中提到】
: your java program:
: time passed: 3891 for your program, I set count to 10^9
: compare to a small c++ program under vs.net 2003. time passed:844
: #include "stdafx.h"
: #include "windows.h"
: int _tmain(int argc, _TCHAR* argv[])
: {
: printf("starting...");
: long re=0;
: long start = GetTickCount();

avatar
st
4
it's commented out in both programs.

【在 e***g 的大作中提到】
: why do you comment out the most expensive part?
avatar
e*g
5
wait, i thought it is in the loop. now this program is too trivial
to test anything.

【在 st 的大作中提到】
: it's commented out in both programs.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。