I have done a little benchmrak comparison between JAVA and C++, with same piece of code, it turns out that JAVA always beats c++ for by small mount. Does it conclude that Java is now faster than C++ ;D?
//compiled with g++ 4.6.3
#include <iostream>
#include <ctime>
int main(){
clock_t begin = clock();
double *numbers;
numbers = new double[32000000];
double sum = 0;
for(int i = 0; i < 32000000;i++){
numbers[i] = 3141592654.987654321/i;
sum+= i/3.141592654987654321/(i+3.14159269876)/(3.14159269876 -i)/(35343.34534 -i)/(3343443242.33 -i)/numbers[i];
}
clock_t end = clock();
double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
std::cout << sum << "\n" ;
std::cout << elapsed_secs;
return 0;
}
//compiled with java 1.6.27
public class test{
public static void main(String[] args){
long time = System.currentTimeMillis();
double[] numbers = new double[32000000];
double sum = 0;
for(int i = 0; i < 32000000;i++){
numbers[i] = 3141592654.987654321/i;
sum+= i/3.141592654987654321/(i+3.14159269876)/(3.14159269876 -i)/(35343.34534-i)/(3343443242.33 -i)/numbers[i];
}
System.out.println(sum);
System.out.println(System.currentTimeMillis() - time);
}
}