s******M 发帖数: 3435 | 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; i
re = re+i;
}
long dur = System.currentTim |
st 发帖数: 1685 | 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; i
re = 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;
|
e***g 发帖数: 158 | 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();
|
st 发帖数: 1685 | 4 it's commented out in both programs.
【在 e***g 的大作中提到】 : why do you comment out the most expensive part?
|
e***g 发帖数: 158 | 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.
|