I am iterating over a set of objects in a for-loop and for each object the same graph is generated at one point. I happened to recognize that the graph generation for the first object always has a longer runtime compared to the others.
I suppose that's because of some kind of optimization that's recognized after the first iteration. The problem is that I'd like to compare the runtimes for the objects which should be based on the same conditions for each of them of course.
What kind of optimization is this and can it be disabled?
Edit: Here's a shortened example of the code inside the for-loop:
double startTime = System.currentTimeMillis();
Graph g = new Graph();
for (int entry : entries) {
graph.addVertex("v" + entry);
}
System.out.println("runtime: " + (System.currentTimeMillis() - startTime) / 1000.0);
Edit: Here are the measurements for the first few loops:
runtime: 0.045
runtime: 0.001
runtime: 0.001
runtime: 0.002
runtime: 0.002