Simple Java programm runs slow on Windows 2008 Server
This question already has an answer here:
I would take a look at the differences in processor. Server systems are most of the time optimized for writing stuff to disk, not in doing calculations. Looking at the processor speeds alone, they are completely different 3.4 GHz vs 1.6 GHz based on that information only I would say the 3.4 should be much faster than the 1.6 GHz.
To be sure find some benchmark information on the two systems.
Of course, because the server processor is much slower, for me it seems perfectly fine result, from my calculations (for this test) the XEON 1.6 Ghz processor has 61% computation efficiency (per Ghz) of that i7 one. But, the i7 could also boost frequency from 3.4 to 3.8 Ghz on demand (Turbo Bost), so this could affect your test. Try to install another java VM and repeat that test. If you will be unsure after that, try running this on a linux (run an live linux image or something with java). There's many factors that can contribute to the result, memory speed is another one. You could also compare the processors GFLOPS values, this could give you a hint about efficiency, but as stated in some comment below your question, microbenchmarks are not very useful at measuring something.
When you test sub-optimal code which you wouldn't normally write you are testing some of the specific behaviour of that processor. There is every chance one processor design might perform one operation much slower than another but on balance in real programs this doesn't show up.
The simplest solution is attempt to optimise the code and you might find it's much faster on both machines.
double sum = 0;
for (int a=1; a < 1000000; a++) {
int input = 100;
for(int counter = 1; counter < input; counter += 2){
sum += 1.0 / (2 * counter - 1) - 1 / (2 * counter + 1);
// or
// sum += 2.0 / ((2 * counter - 1) * (2 * counter + 1));
}
}
Note: Math.pow is a very expensive operation.
链接地址: http://www.djcxy.com/p/86552.html