My code looks like this:
public static int counter = 0;
public static void operation() {
counter++;
}
public static void square(int n) {
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
operation();
}
public static void main(String[] args) {
System.out.println("Start...");
long start = System.nanoTime();
square(350000);
long end = System.nanoTime();
System.out.println("Run time: " + ((end - start) / 1000000)
+ " ms");
}
I tried to run this code with IntelliJ and it took 6 500 ms, while Eclipse was much more faster with 18 ms. I'm using Skylake CPU, Java 11. Both are set on same settings and I didn't change a thing in settings.
Is there a way / How can I optimize IntelliJ to get same results as Eclipse?
Thanks.