Skip to content
This repository was archived by the owner on Jul 12, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 52 additions & 23 deletions graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ type Graph struct {
Title string
HeapUse, ScvgInuse, ScvgIdle []graphPoints
ScvgSys, ScvgReleased, ScvgConsumed []graphPoints
STWSclock []graphPoints
MASclock []graphPoints
STWMclock []graphPoints
STWScpu []graphPoints
MASAssistcpu []graphPoints
MASBGcpu []graphPoints
MASIdlecpu []graphPoints
STWMcpu []graphPoints
STWSclock, AccumSTWSclock []graphPoints
MASclock, AccumMASclock []graphPoints
STWMclock, AccumSTWMclock []graphPoints
STWScpu, AccumSTWScpu []graphPoints
MASAssistcpu, AccumMASAssistcpu []graphPoints
MASBGcpu, AccumMASBGcpu []graphPoints
MASIdlecpu, AccumMASIdlecpu []graphPoints
STWMcpu, AccumSTWMcpu []graphPoints
Tmpl *template.Template `json:"-"`
mu sync.RWMutex `json:"-"`
}
Expand All @@ -29,21 +29,29 @@ var StartTime = time.Now()

func NewGraph(title, tmpl string) Graph {
g := Graph{
Title: title,
HeapUse: []graphPoints{},
ScvgInuse: []graphPoints{},
ScvgIdle: []graphPoints{},
ScvgSys: []graphPoints{},
ScvgReleased: []graphPoints{},
ScvgConsumed: []graphPoints{},
STWSclock: []graphPoints{},
MASclock: []graphPoints{},
STWMclock: []graphPoints{},
STWScpu: []graphPoints{},
MASAssistcpu: []graphPoints{},
MASBGcpu: []graphPoints{},
MASIdlecpu: []graphPoints{},
STWMcpu: []graphPoints{},
Title: title,
HeapUse: []graphPoints{},
ScvgInuse: []graphPoints{},
ScvgIdle: []graphPoints{},
ScvgSys: []graphPoints{},
ScvgReleased: []graphPoints{},
ScvgConsumed: []graphPoints{},
STWSclock: []graphPoints{},
MASclock: []graphPoints{},
STWMclock: []graphPoints{},
STWScpu: []graphPoints{},
MASAssistcpu: []graphPoints{},
MASBGcpu: []graphPoints{},
MASIdlecpu: []graphPoints{},
STWMcpu: []graphPoints{},
AccumSTWSclock: []graphPoints{},
AccumMASclock: []graphPoints{},
AccumSTWMclock: []graphPoints{},
AccumSTWScpu: []graphPoints{},
AccumMASAssistcpu: []graphPoints{},
AccumMASBGcpu: []graphPoints{},
AccumMASIdlecpu: []graphPoints{},
AccumSTWMcpu: []graphPoints{},
}
g.setTmpl(tmpl)

Expand Down Expand Up @@ -78,6 +86,27 @@ func (g *Graph) AddGCTraceGraphPoint(gcTrace *gctrace) {
g.MASBGcpu = append(g.MASBGcpu, graphPoints{elapsedTime, float64(gcTrace.MASBGcpu)})
g.MASIdlecpu = append(g.MASIdlecpu, graphPoints{elapsedTime, float64(gcTrace.MASIdlecpu)})
g.STWMcpu = append(g.STWMcpu, graphPoints{elapsedTime, float64(gcTrace.STWMcpu)})
prevIdx := len(g.AccumSTWSclock) - 1
if prevIdx == -1 {
g.AccumSTWSclock = append(g.AccumSTWSclock, graphPoints{elapsedTime, float64(gcTrace.STWSclock)})
g.AccumMASclock = append(g.AccumMASclock, graphPoints{elapsedTime, float64(gcTrace.MASclock)})
g.AccumSTWMclock = append(g.AccumSTWMclock, graphPoints{elapsedTime, float64(gcTrace.STWMclock)})
g.AccumSTWScpu = append(g.AccumSTWScpu, graphPoints{elapsedTime, float64(gcTrace.STWScpu)})
g.AccumMASAssistcpu = append(g.AccumMASAssistcpu, graphPoints{elapsedTime, float64(gcTrace.MASAssistcpu)})
g.AccumMASBGcpu = append(g.AccumMASBGcpu, graphPoints{elapsedTime, float64(gcTrace.MASBGcpu)})
g.AccumMASIdlecpu = append(g.AccumMASIdlecpu, graphPoints{elapsedTime, float64(gcTrace.MASIdlecpu)})
g.AccumSTWMcpu = append(g.AccumSTWMcpu, graphPoints{elapsedTime, float64(gcTrace.STWMcpu)})
} else {
g.AccumSTWSclock = append(g.AccumSTWSclock, graphPoints{elapsedTime, g.AccumSTWSclock[prevIdx][1] + float64(gcTrace.STWSclock)})
g.AccumMASclock = append(g.AccumMASclock, graphPoints{elapsedTime, g.AccumMASclock[prevIdx][1] + float64(gcTrace.MASclock)})
g.AccumSTWMclock = append(g.AccumSTWMclock, graphPoints{elapsedTime, g.AccumSTWMclock[prevIdx][1] + float64(gcTrace.STWMclock)})
g.AccumSTWScpu = append(g.AccumSTWScpu, graphPoints{elapsedTime, g.AccumSTWScpu[prevIdx][1] + float64(gcTrace.STWScpu)})
g.AccumMASAssistcpu = append(g.AccumMASAssistcpu, graphPoints{elapsedTime, g.AccumMASAssistcpu[prevIdx][1] + float64(gcTrace.MASAssistcpu)})
g.AccumMASBGcpu = append(g.AccumMASBGcpu, graphPoints{elapsedTime, g.AccumMASBGcpu[prevIdx][1] + float64(gcTrace.MASBGcpu)})
g.AccumMASIdlecpu = append(g.AccumMASIdlecpu, graphPoints{elapsedTime, g.AccumMASIdlecpu[prevIdx][1] + float64(gcTrace.MASIdlecpu)})
g.AccumSTWMcpu = append(g.AccumSTWMcpu, graphPoints{elapsedTime, g.AccumSTWMcpu[prevIdx][1] + float64(gcTrace.STWMcpu)})
}

}

func (g *Graph) AddScavengerGraphPoint(scvg *scvgtrace) {
Expand Down
121 changes: 73 additions & 48 deletions template.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ const (
{ label: "con mas idle cpu", data: {{ .MASIdlecpu }} },
{ label: "STW mark cpu", data: {{ .STWMcpu }} },
];
var accum_clockgraph_data = [
{ label: "STW sweep clock", data: {{ .AccumSTWSclock }} },
{ label: "con mas clock", data: {{ .AccumMASclock }} },
{ label: "STW mark clock", data: {{ .AccumSTWMclock }} },
];
var accum_cpugraph_data = [
{ label: "STW sweep cpu", data: {{ .AccumSTWScpu }} },
{ label: "con mas assist cpu", data: {{ .AccumMASAssistcpu }} },
{ label: "con mas bg cpu", data: {{ .AccumMASBGcpu }} },
{ label: "con mas idle cpu", data: {{ .AccumMASIdlecpu }} },
{ label: "STW mark cpu", data: {{ .AccumSTWMcpu }} },
];

var timingsgraph_options = {
legend: {
Expand Down Expand Up @@ -78,9 +90,11 @@ const (
};

$(document).ready(function() {
var datagraph = $.plot("#datagraph", datagraph_data, datagraph_options);
var clockgraph = $.plot("#clockgraph", clockgraph_data, timingsgraph_options);
var cpugraph = $.plot("#cpugraph", cpugraph_data, timingsgraph_options);
var datagraph = $.plot("#datagraph", datagraph_data, datagraph_options);
var clockgraph = $.plot("#clockgraph", clockgraph_data, timingsgraph_options);
var accumclockgraph = $.plot("#accumclockgraph", accum_clockgraph_data, timingsgraph_options);
var cpugraph = $.plot("#cpugraph", cpugraph_data, timingsgraph_options);
var accumcpugraph = $.plot("#accumcpugraph", accum_cpugraph_data, timingsgraph_options);

var overview = $.plot("#overview", {}, {
legend: { show: false},
Expand All @@ -106,67 +120,51 @@ const (
}
});

// now connect the four
$("#datagraph").bind("plotselected", function (event, ranges) {

function updateZoom(g, ranges) {
// do the zooming
$.each(datagraph.getXAxes(), function(_, axis) {
$.each(g.getXAxes(), function(_, axis) {
var opts = axis.options;
opts.min = ranges.xaxis.from;
opts.max = ranges.xaxis.to;
});
datagraph.setupGrid();
datagraph.draw();
datagraph.clearSelection();

// don't fire event on the overview to prevent eternal loop
overview.setSelection(ranges, true);
clockgraph.setSelection(ranges, true);
cpugraph.setSelection(ranges, true);
});
g.setupGrid();
g.draw();
g.clearSelection();
updateRanges(g, ranges);
}

$("#clockgraph").bind("plotselected", function (event, ranges) {
function updateRanges(g, ranges) {
if (g !== overview) { overview.setSelection(ranges, true); }
if (g !== datagraph) { datagraph.setSelection(ranges, true); }
if (g !== clockgraph) { clockgraph.setSelection(ranges, true); }
if (g !== accumclockgraph) { accumclockgraph.setSelection(ranges, true); }
if (g !== cpugraph) { cpugraph.setSelection(ranges, true); }
if (g !== accumcpugraph) { accumcpugraph.setSelection(ranges, true); }
}

// do the zooming
$.each(clockgraph.getXAxes(), function(_, axis) {
var opts = axis.options;
opts.min = ranges.xaxis.from;
opts.max = ranges.xaxis.to;
});
clockgraph.setupGrid();
clockgraph.draw();
clockgraph.clearSelection();
// now connect everything
$("#datagraph").bind("plotselected", function (event, ranges) {
updateZoom(datagraph, ranges);
});

// don't fire event on the overview to prevent eternal loop
$("#clockgraph").bind("plotselected", function (event, ranges) {
updateZoom(clockgraph, ranges);
});

overview.setSelection(ranges, true);
datagraph.setSelection(ranges, true);
cpugraph.setSelection(ranges, true);
$("#accumclockgraph").bind("plotselected", function (event, ranges) {
updateZoom(accumclockgraph, ranges);
});

$("#cpugraph").bind("plotselected", function (event, ranges) {
updateZoom(cpugraph, ranges);
});

// do the zooming
$.each(cpugraph.getXAxes(), function(_, axis) {
var opts = axis.options;
opts.min = ranges.xaxis.from;
opts.max = ranges.xaxis.to;
});
cpugraph.setupGrid();
cpugraph.draw();
cpugraph.clearSelection();

// don't fire event on the overview to prevent eternal loop

overview.setSelection(ranges, true);
datagraph.setSelection(ranges, true);
clockraph.setSelection(ranges, true);
$("#accumcpugraph").bind("plotselected", function (event, ranges) {
updateZoom(accumcpugraph, ranges);
});

$("#overview").bind("plotselected", function (event, ranges) {
datagraph.setSelection(ranges);
clockgraph.setSelection(ranges);
cpugraph.setSelection(ranges);
updateRanges(overview, ranges);
});

// refresh data every second
Expand All @@ -187,13 +185,25 @@ const (
{ label: "con mas clock", data: graphData.MASclock },
{ label: "STW mark clock", data: graphData.STWMclock },
];
var accum_clockgraph_data = [
{ label: "Accumulated STW sweep clock", data: graphData.AccumSTWSclock },
{ label: "Accumulated con mas clock", data: graphData.AccumMASclock },
{ label: "Accumulated STW mark clock", data: graphData.AccumSTWMclock },
];
var cpugraph_data = [
{ label: "STW sweep cpu", data: graphData.STWScpu },
{ label: "con mas assist cpu", data: graphData.MASAssistcpu },
{ label: "con mas bg cpu", data: graphData.MASBGcpu },
{ label: "con mas idle cpu", data: graphData.MASIdlecpu },
{ label: "STW mark cpu", data: graphData.STWMcpu },
];
var accum_cpugraph_data = [
{ label: "Accumulated STW sweep cpu", data: graphData.AccumSTWScpu },
{ label: "Accumulated con mas assist cpu", data: graphData.AccumMASAssistcpu },
{ label: "Accumulated con mas bg cpu", data: graphData.AccumMASBGcpu },
{ label: "Accumulated con mas idle cpu", data: graphData.AccumMASIdlecpu },
{ label: "Accumulated STW mark cpu", data: graphData.AccumSTWMcpu },
];

datagraph.setData(datagraph_data);
datagraph.setupGrid();
Expand All @@ -203,10 +213,18 @@ const (
clockgraph.setupGrid();
clockgraph.draw();

accumclockgraph.setData(accum_clockgraph_data);
accumclockgraph.setupGrid();
accumclockgraph.draw();

cpugraph.setData(cpugraph_data);
cpugraph.setupGrid();
cpugraph.draw();

accumcpugraph.setData(accum_cpugraph_data);
accumcpugraph.setupGrid();
accumcpugraph.draw();

overview.setData(datagraph_data);
overview.setupGrid();
overview.draw();
Expand Down Expand Up @@ -313,10 +331,17 @@ dd { margin-left: 160px; }
<div id="clockgraph" class="demo-placeholder"></div>
</div>

<div class="small-graph-container">
<div id="accumclockgraph" class="demo-placeholder"></div>
</div>
<div class="small-graph-container">
<div id="cpugraph" class="demo-placeholder"></div>
</div>

<div class="small-graph-container">
<div id="accumcpugraph" class="demo-placeholder"></div>
</div>

<div class="legend-container" style="height:60px;">
<div id="overview" class="demo-placeholder"></div>
</div>
Expand Down