in src/main/java/org/adoptopenjdk/jitwatch/ui/graphing/CodeCachePanel.java [38:138]
protected void paintGraph(Graphics g)
{
super.paintGraph(g);
Graphics2D g2d = (Graphics2D) g;
labelLeft = true;
List<CodeCacheEvent> codeCacheEvents = mainUI.getJITDataModel().getCodeCacheEvents();
Collections.sort(codeCacheEvents, Comparator.comparingLong(CodeCacheEvent::getStamp));
if (!codeCacheEvents.isEmpty())
{
CodeCacheEvent firstEvent = codeCacheEvents.get(0);
minX = firstEvent.getStamp();
double firstNonZeroY = 0;
Tag endOfLogTag = mainUI.getJITDataModel().getEndOfLogTag();
if (endOfLogTag != null)
{
maxX = getStampFromTag(endOfLogTag);
}
else
{
CodeCacheEvent lastEvent = codeCacheEvents.get(codeCacheEvents.size() - 1);
maxX = lastEvent.getStamp();
}
minY = firstEvent.getFreeCodeCache();
maxY = firstEvent.getFreeCodeCache();
if (minY != 0)
{
firstNonZeroY = minY;
}
// Find ranges
for (CodeCacheEvent event : codeCacheEvents)
{
long freeCodeCache = event.getFreeCodeCache();
if (freeCodeCache > 0)
{
if (minY == 0)
{
minY = freeCodeCache;
firstNonZeroY = minY;
}
if (freeCodeCache > maxY)
{
maxY = freeCodeCache;
}
else if (freeCodeCache < minY)
{
minY = freeCodeCache;
}
}
}
drawAxes(g2d);
double lastCX = graphGapLeft + normaliseX(minX);
double lastCY = graphGapTop + normaliseY(firstNonZeroY);
Color colourLine = Color.BLUE;
float lineWidth = 2.0f;
for (CodeCacheEvent event : codeCacheEvents)
{
long stamp = event.getStamp();
double x = graphGapLeft + normaliseX(stamp);
double y = lastCY;
switch (event.getEventType())
{
case COMPILATION:
y = addToGraph(g2d, lastCX, lastCY, colourLine, lineWidth, event, x);
lastCX = x;
lastCY = y;
break;
case SWEEPER:
showLabel(g2d, "Sweep", Color.WHITE, x, y);
break;
case CACHE_FULL:
showLabel(g2d, "Code Cache Full", Color.RED, x, y);
break;
}
}
continueLineToEndOfXAxis(g2d, lastCX, lastCY, colourLine, lineWidth);
}
else
{
g2d.drawString("No code cache information in log", 10, 10);
}
}