0

I have a loop with 701 iterations of similar complex calculations. I measured the execution time of each iteration for three runs. As you can see in the chart I'm getting strange peaks. Is there any common aproach which is able to explain these peaks without analyzing the code inside the loop. Execution Time

Is it possible that the gc is starting at these points and slow down the other parts?

  • It depends. If you don't want to analyze the code inside the loop you have to analyze the usage of memory during excution. – Aris2World May 20 '16 at 12:48
  • 1
    Furthermore, it is well possible that the JIT-compiler kicked in and hot-compiled the code. For more information, you may want to read [this question about micro-benchmarks](http://stackoverflow.com/questions/504103/how-do-i-write-a-correct-micro-benchmark-in-java). – Turing85 May 20 '16 at 12:56
  • I had not the time to follow your links yet, but I tracked the used memory `((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/1000000)` – Bastian Hermann May 20 '16 at 13:20
  • At duration peaks it seems that the gc did his job: frameNo: 77, Frame writing time: 34.94403, Memory in usage: 687mb frameNo: 78, Frame writing time: 724.741449, Memory in usage: 107mb – Bastian Hermann May 20 '16 at 13:21
  • @BastianHermann Yes, it seems a full gc. If you want to have more infos use the log...Luke... ;) – Aris2World May 20 '16 at 15:34

1 Answers1

0

It depends.

If you don't want to analyze the code inside the loop you have to analyze at least the usage of memory during excution. For example if algorithm does not create many garbage and you have configured enough heap and you have chosen the right gc algorithm then the gc does not require any "stop the world".

As first thing you have to activate gc logging (see here: http://www.oracle.com/technetwork/articles/javase/gcportal-136937.html) and check for gc peaks in correspondance to your time peaks.

If you want to analyze the gc log you can use this tool http://www.tagtraum.com/gcviewer.html.

Then follow the link posted from Turing85 about micro-benchmarks. It is more complete.

Aris2World
  • 1,214
  • 12
  • 22