I have following piece of code:
List<Long> array = new ArrayList<>();
for (int i = 0; i < 30000; i++)
{
array.add(Long.valueOf(i));
}
for (int j = 0; j < 30000; j++)
{
for (int i = 0; i < 30000 - j; i++)
{
array.set(i, array.get(i) + j);
}
}
When I compile it and run it under Oracle JVM on my local machine (JRE 1.7_0_71, Win 7 64bit, 4 Cores, 8GB RAM), I get times around 3,5s for run.
1.run: 3446ms
2.run: 3485ms
3.run: 3546ms
4.run: 3721ms
5.run: 3573ms
When I run it on AIX machine (POWER7+, 16 Cores, 64GB RAM) with IBM JVM (j9, java 7,build pap6470_27sr2-20141101_01(SR2)), I get results at almost 9s per run.
1.run: 8518ms
2.run: 8548ms
3.run: 8499ms
4.run: 8486ms
5.run: 9235ms
Any idea where could be catch?
You have 3 issues.
Of these, the biggest impact in this case will be the IBM JRE which has really poor performance for loops. Were you doing file work, you'd find it was slow due to the operating system. There are many many causes of slowness with this combination, your best bet is to move to x86, Linux and Oracle.