cipicip
Geek Trainee
Hi guys!
I got a puzzle for you.
During a period of boredom , I wrote this little program in java (initially was in C++) and ran it on WinXPpro and Linux FC3. Basically it’s a benchmark program. Returns the total number of cycles the program executes in 30 seconds.
And surprise! The windows executes around 200 millions cycles, while the Linux around 20 millions. The C++ version returned even a greater difference 320 : 15 which made me consider the possibility that this problem might have something to do with the compiler (VS 2003 vs. g++) and so wrote the same program in java.
My pc is a dual boot P4 @3GHz 800MHz bus. I stopped almost every service in Linux (except for network and some others related with the optimization) even if the Windows runs lots of services too.
Can anyone replicate these results? Can anyone explain this?
And for those of you who might be wondering, I’m not a Windows fan nor a Linux one.
//------------------- START ------------------------
import java.util.*;
public class Benchmark {
public static void main(String[] args) {
int k = 0;
long counter = 0;
long presentNoSec = 0;
long initialNoSec = 0;
float[] values = new float[1000];
Date refDate = new Date();
initialNoSec = refDate.getTime();
for(int i=0; i< 1000 ; i++)
{
values = (float)(Math.random() * 1000);
}
System.out.println("And here we go...");
for(counter=0; (presentNoSec - initialNoSec) < (30 * 1000) ; counter++)
{
refDate = new Date();
presentNoSec = refDate.getTime();
if(k%2 == 0)
values[k] /= values[k + 500];
else
values[k] += values[k + 500];
k++;
if(k>=500)
k=0;
}
System.out.println("Total no. of cicles: " + Long.toString(counter));
}
}
//----------------- END -----------------------
I got a puzzle for you.
During a period of boredom , I wrote this little program in java (initially was in C++) and ran it on WinXPpro and Linux FC3. Basically it’s a benchmark program. Returns the total number of cycles the program executes in 30 seconds.
And surprise! The windows executes around 200 millions cycles, while the Linux around 20 millions. The C++ version returned even a greater difference 320 : 15 which made me consider the possibility that this problem might have something to do with the compiler (VS 2003 vs. g++) and so wrote the same program in java.
My pc is a dual boot P4 @3GHz 800MHz bus. I stopped almost every service in Linux (except for network and some others related with the optimization) even if the Windows runs lots of services too.
Can anyone replicate these results? Can anyone explain this?
And for those of you who might be wondering, I’m not a Windows fan nor a Linux one.
//------------------- START ------------------------
import java.util.*;
public class Benchmark {
public static void main(String[] args) {
int k = 0;
long counter = 0;
long presentNoSec = 0;
long initialNoSec = 0;
float[] values = new float[1000];
Date refDate = new Date();
initialNoSec = refDate.getTime();
for(int i=0; i< 1000 ; i++)
{
values = (float)(Math.random() * 1000);
}
System.out.println("And here we go...");
for(counter=0; (presentNoSec - initialNoSec) < (30 * 1000) ; counter++)
{
refDate = new Date();
presentNoSec = refDate.getTime();
if(k%2 == 0)
values[k] /= values[k + 500];
else
values[k] += values[k + 500];
k++;
if(k>=500)
k=0;
}
System.out.println("Total no. of cicles: " + Long.toString(counter));
}
}
//----------------- END -----------------------