Skip to content

Commit

Permalink
Merge pull request #614 from StanfordVL/profiling
Browse files Browse the repository at this point in the history
Fix profiling webpage display bugs
  • Loading branch information
cgokmen authored Feb 22, 2024
2 parents 8e15a1a + 4966c74 commit c05e93a
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions scripts/profiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,26 @@ function renderGraph(canvasName, fieldName, runNames) {
const canvas = document.getElementById(canvasName);
const color = ['#178600', '#00add8', '#ffa500', '#ff3838'];
const data = {
labels: Array.from(filteredData).map(([_name, value]) => (value[0].commit.id.slice(0, 7))),
datasets: Array.from(filteredData).map(([name, value], index) => ({
label: name,
data: value.map(d => d.bench.value),
borderColor: color[index],
backgroundColor: 'rgba(0, 0, 0, 0.01)'
}))
labels: Array.from(filteredData.values())[0].map(value => value.commit.id.slice(0, 7)),
datasets: Array.from(filteredData).map(([name, value], index) => {
return {
label: name,
data: value.map(d => ({
'x': d.commit.id.slice(0, 7),
'y': d.bench.value
}
)),
borderColor: color[index],
backgroundColor: 'rgba(0, 0, 0, 0.01)'
};
})
};
const options = {
tooltips: {
callbacks: {
afterTitle: items => {
const {index} = items[0];
const data = filteredData.values().next().value[index];
const {datasetIndex, index} = items[0];
const data = Array.from(filteredData.values())[datasetIndex][index];
return '\n' + data.commit.message + '\n\n' + data.commit.timestamp + ' committed by @' + data.commit.committer.username + '\n';
},
label: item => {
Expand All @@ -122,13 +128,12 @@ function renderGraph(canvasName, fieldName, runNames) {
}
}
},
onClick: (_mouseEvent, activeElems) => {
if (activeElems.length === 0) {
onClick: (_mouseEvent) => {
const points = myChart.getElementsAtEventForMode(_mouseEvent, 'nearest', { intersect: true }, true);
if (points.length === 0) {
return;
}
// XXX: Undocumented. How can we know the index?
const index = activeElems[0]._index;
const url = filteredData.values().next().value[index].commit.url;
const url = Array.from(filteredData.values())[points[0]._datasetIndex][points[0]._index].commit.url;
window.open(url, '_blank');
},
title: {
Expand All @@ -142,11 +147,12 @@ function renderGraph(canvasName, fieldName, runNames) {
maintainAspectRatio: true
};

new Chart(canvas, {
const myChart = new Chart(canvas, {
type: 'line',
data,
options,
});
return myChart;
}


Expand Down

0 comments on commit c05e93a

Please sign in to comment.