Commit 943aa6e2 authored by Simon Tenbusch's avatar Simon Tenbusch

[sequencechart]

Implemented visualization of parallelism on the critical path:
The overlapping CPU time for each event is counted and visualized via color information
parent 97e29f40
......@@ -176,6 +176,7 @@ public class SequenceChartContributor extends EditorActionBarContributor impleme
protected SequenceChartAction showEventOverlappingAction;
protected SequenceChartAction showCriticalPathAction;
protected SequenceChartAction showCriticalPathColorsAction;
protected SequenceChartAction previousBottleneckAction;
protected SequenceChartAction nextBottleneckAction;
......@@ -224,6 +225,7 @@ public class SequenceChartContributor extends EditorActionBarContributor impleme
this.showEventNumbersAction = createShowEventNumbersAction();
this.showEventOverlappingAction = createShowEventOverlappingAction();
this.showCriticalPathAction = createShowCriticalPathAction();
this.showCriticalPathColorsAction = createShowCriticalPathColorsAction();
this.previousBottleneckAction = createPreviousBottleneckAction();
this.nextBottleneckAction = createNextBottleneckAction();
this.showBottleneckPreferencesAction = createShowBottleneckPreferencesAction();
......@@ -362,6 +364,7 @@ public class SequenceChartContributor extends EditorActionBarContributor impleme
showHideSubmenu.add(showEventNumbersAction);
showHideSubmenu.add(showEventOverlappingAction);
showHideSubmenu.add(showCriticalPathAction);
showHideSubmenu.add(showCriticalPathColorsAction);
showHideSubmenu.add(showMessageNamesAction);
showHideSubmenu.add(showArrowHeadsAction);
showHideSubmenu.add(showAxisLabelsAction);
......@@ -436,6 +439,7 @@ public class SequenceChartContributor extends EditorActionBarContributor impleme
toolBarManager.add(showEventNumbersAction);
toolBarManager.add(showEventOverlappingAction);
toolBarManager.add(showCriticalPathAction);
toolBarManager.add(showCriticalPathColorsAction);
toolBarManager.add(showMessageNamesAction);
toolBarManager.add(showMessageSendsAction);
toolBarManager.add(showSelfMessagesAction);
......@@ -944,6 +948,27 @@ public class SequenceChartContributor extends EditorActionBarContributor impleme
};
}
private SequenceChartAction createShowCriticalPathColorsAction() {
return new SequenceChartAction("Show Critical Path Colors", Action.AS_CHECK_BOX, SequenceChartPlugin.getImageDescriptor(IMAGE_SHOW_CRITICAL_PATH)) {
@Override
protected void doRun() {
sequenceChart.setShowCriticalPathColors(!sequenceChart.getShowCriticalPathColors());
sequenceChart.setShowEventOverlapping(false);
update();
}
@Override
public void update() {
setChecked(sequenceChart.getShowCriticalPathColors());
showEventOverlappingAction.setChecked(sequenceChart.getShowEventOverlapping());
}
@Override
public boolean isEnabled() {
return sequenceChart!=null && !sequenceChart.isLegacyTrace();
}
};
}
private SequenceChartAction createPreviousBottleneckAction() {
return new SequenceChartAction("Jump to previous Bottleneck", Action.AS_PUSH_BUTTON, SequenceChartPlugin.getImageDescriptor(IMAGE_JUMP_TO_PREVIOUS_BOTTLENECK)) {
@Override
......
......@@ -152,8 +152,8 @@ public class SequenceChart
private static final Color OVERLAPPING_EVENT_BACKGROUND_COLOR = ColorFactory.DARK_BLUE;
private static final Color NON_OVERLAPPING_EVENT_BACKGROUND_COLOR = ColorFactory.LIGHT_BLUE;
private static final Color CRITICAL_EVENT_BACKGROUND_COLOR = ColorFactory.DARK_RED;
private static final Color NON_CRITICAL_EVENT_BACKGROUND_COLOR = ColorFactory.SALMON;
private static final Color CRITICAL_EVENT_BACKGROUND_COLOR = ColorFactory.DARK_BLUE;
private static final Color NON_CRITICAL_EVENT_BACKGROUND_COLOR = ColorFactory.LIGHT_BLUE;
private static final Color SELF_EVENT_BACKGROUND_COLOR = ColorFactory.GREEN2;
......@@ -190,7 +190,7 @@ public class SequenceChart
private int fontHeight = -1; // cached for cases where a graphics is not available
private static final int CRITICAL_PATH_LINE_WIDTH = 3+3; // line width for message dependencies on the critical path
private static final Color CRITICAL_PATH_LINE_COLOR = ColorFactory.RED; // line color for message dependencies on the critical path
private static final Color CRITICAL_PATH_LINE_COLOR = ColorFactory.BLUE; // line color for message dependencies on the critical path
/*************************************************************************************
......@@ -220,6 +220,7 @@ public class SequenceChart
private boolean showEventNumbers = true;
private boolean showEventOverlapping = false;
private boolean showCriticalPath = false;
private boolean showCriticalPathColors = false;
private boolean showZeroSimulationTimeRegions = true;
private boolean showAxisLabels = true;
private boolean showAxesWithoutEvents = false;
......@@ -667,6 +668,21 @@ public class SequenceChart
clearCanvasCacheAndRedraw();
}
/**
* Returns whether critical path colors are shown on the chart.
*/
public boolean getShowCriticalPathColors() {
return showCriticalPathColors;
}
/**
* Shows/Hides critical path colors.
*/
public void setShowCriticalPathColors(boolean showCriticalPathColors) {
this.showCriticalPathColors = showCriticalPathColors;
clearCanvasCacheAndRedraw();
}
/**
* Shows/hides arrow heads.
*/
......@@ -2550,7 +2566,6 @@ public class SequenceChart
long startEventPtr = eventPtrRange[0];
long endEventPtr = eventPtrRange[1];
if (showZeroSimulationTimeRegions)
drawZeroSimulationTimeRegions(graphics, startEventPtr, endEventPtr);
......@@ -2761,7 +2776,7 @@ public class SequenceChart
if (debug)
Debug.println("Drawing events with event range: " + sequenceChartFacade.IEvent_getEventNumber(startEventPtr) + " ->: " + sequenceChartFacade.IEvent_getEventNumber(endEventPtr));
HashMap<Integer, Integer> axisYtoLastX = new HashMap<Integer, Integer>();
//HashMap<Integer, Integer> axisYtoLastX = new HashMap<Integer, Integer>();
// NOTE: navigating through next event takes care about leaving events out which are not in the filter's result
for (long eventPtr = startEventPtr;; eventPtr = sequenceChartFacade.IEvent_getNextEvent(eventPtr)) {
......@@ -2770,13 +2785,13 @@ public class SequenceChart
else {
int x = (int)getEventXViewportCoordinate(eventPtr);
int y = getEventYViewportCoordinate(eventPtr);
Integer lastX = axisYtoLastX.get(y);
// Integer lastX = axisYtoLastX.get(y);
// performance optimization: don't draw event if there's one already drawn exactly there
if (lastX == null || lastX.intValue() != x) {
axisYtoLastX.put(y, x);
//if (lastX == null || lastX.intValue() != x) {
//axisYtoLastX.put(y, x);
drawEvent(graphics, eventPtr, getEventAxisModuleIndex(eventPtr), x, y);
}
//}
}
if (eventPtr == endEventPtr)
......@@ -2928,32 +2943,42 @@ public class SequenceChart
}
break;
case DURATION: // Show Complexity as colors
{ double intensity = getComplexityPercentage(sequenceChartFacade
.IEvent_getEvent(eventPtr)
.getComplexity());
graphics
.setBackgroundColor(new Color(
null,
(int)(255 * (getComplexityPercentage(sequenceChartFacade
.IEvent_getEvent(eventPtr)
.getComplexity()))),
(int)(255 - 255 * (getComplexityPercentage(sequenceChartFacade
.IEvent_getEvent(eventPtr)
.getComplexity()))), 0));
(int)(255 * Math.pow(intensity, 1/3.0)),
(int)(255 - 255 * Math.pow(intensity, 1/3.0)), 0));
break;
}
case COMPLEXITY: // Show Duration as colors
{
double intensity = getEventLengthPercentage(sequenceChartFacade
.IEvent_getEvent(eventPtr)
.getEventEntry().getDuration());
graphics
.setBackgroundColor(new Color(
null,
(int)(255 * (getEventLengthPercentage(sequenceChartFacade
.IEvent_getEvent(eventPtr)
.getEventEntry().getDuration()))),
(int)(255 - 255 * (getEventLengthPercentage(sequenceChartFacade
.IEvent_getEvent(eventPtr)
.getEventEntry().getDuration()))), 0));
(int)(255 * Math.pow(intensity, 1/3.0)),
(int)(255 - 255 * Math.pow(intensity, 1/3.0)), 0));
break;
}
}
} else if (showCriticalPath){
graphics.setForegroundColor(EVENT_BORDER_COLOR);
if (sequenceChartFacade.isOnCriticalPath(sequenceChartFacade.IEvent_getEvent(eventPtr))) {
graphics.setBackgroundColor(CRITICAL_EVENT_BACKGROUND_COLOR);
if(showCriticalPathColors) {
double intensity = sequenceChartFacade.getOverlappingQuotient(eventPtr);
graphics
.setBackgroundColor(new Color(
null,
(int)(255-255 * Math.pow(intensity, 1/3.0)),
(int)(255 * Math.pow(intensity, 1/3.0)),0));
} else {
graphics.setBackgroundColor(CRITICAL_EVENT_BACKGROUND_COLOR);
}
} else {
graphics.setBackgroundColor(NON_CRITICAL_EVENT_BACKGROUND_COLOR);
}
......
......@@ -42,6 +42,8 @@ SequenceChartFacade::SequenceChartFacade(IEventLog *eventLog) : EventLogFacade(e
smallestDuration = -1;
largestDuration = -1;
maximumOverlapping = -1;
biggestEarliestProcessingTime = 0;
biggestEndTimeEvent = NULL;
......@@ -1073,3 +1075,65 @@ ptr_t SequenceChartFacade::getLargestEndtimeInEventRange(ptr_t startEventPtr,
}
double SequenceChartFacade::getOverlapping(ptr_t eventPtr) {
long overlapping = 0;
IEvent* event = (IEvent*) eventPtr;
long eventProcessingTime = event->getEarliestProcessingTime();
long eventStartTime = event->getEarliestStartTime();
for (IEvent *current = eventLog->getFirstEvent(); current; current = current->getNextEvent()) {
if(current->getComplexity() == 0) {
continue;
}
long currentStartTime = current->getEarliestStartTime();
long currentProcessingTime = current->getEarliestProcessingTime();
if(eventStartTime <= currentStartTime && eventProcessingTime >= currentStartTime) {
overlapping += eventProcessingTime - currentStartTime;
} else if (currentStartTime <= eventStartTime && currentProcessingTime >= eventStartTime) {
overlapping += currentProcessingTime - eventStartTime;
} else if (currentStartTime <= eventStartTime && currentProcessingTime >= eventProcessingTime) {
overlapping += event->getComplexity();
}
}
printf("overlapping %i %f %i %i\n", overlapping, overlapping / (event->getComplexity() * 1.0), event->getComplexity(), event->getEventNumber());
return overlapping / (event->getComplexity() * 1.0);
}
double SequenceChartFacade::getMaximumOverlapping() {
double maxOverlapping = 0;
for (IEvent *current = eventLog->getFirstEvent(); current; current = current->getNextEvent()) {
if(!isOnCriticalPath(current) || current->getComplexity() == 0) {
continue;
}
double overlapping = getOverlapping((ptr_t) current);
if (overlapping > maxOverlapping){
maxOverlapping = overlapping;
}
}
printf("maxoverlapping %i \n", maxOverlapping);
return maxOverlapping;
}
/*
* returns the quotient of
* relative overlapping cputime with the event / maximum relative overlapping
* cputime with any event of the critical path
*/
double SequenceChartFacade::getOverlappingQuotient(ptr_t eventPtr) {
if (((IEvent*)eventPtr)->getComplexity() == 0) {
return 0;
}
double overlapping = getOverlapping(eventPtr);
if (maximumOverlapping == -1) {
maximumOverlapping = getMaximumOverlapping();
}
return overlapping / maximumOverlapping;
}
......@@ -49,6 +49,8 @@ class EVENTLOG_API SequenceChartFacade : public EventLogFacade
long smallestComplexity;
long largestComplexity;
double maximumOverlapping;
simtime_t smallestDuration;
simtime_t largestDuration;
......@@ -115,6 +117,8 @@ class EVENTLOG_API SequenceChartFacade : public EventLogFacade
*/
simtime_t getLargestEventDuration();
double getOverlappingQuotient(ptr_t eventPtr);
/*
* Returns whether an event not part of a set of parallel events with more than treshold elements.
......@@ -164,6 +168,10 @@ class EVENTLOG_API SequenceChartFacade : public EventLogFacade
void calculateCriticalPath();
double getOverlapping(ptr_t eventPtr);
double getMaximumOverlapping();
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment