Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Empty Graphs #83

Merged
merged 7 commits into from
Oct 4, 2023
Merged
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
14 changes: 6 additions & 8 deletions src/html_files/disk_stats.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let got_disk_stat_data = false;

function getStatValues(run, elem, key, run_data) {
function getStatValues(elem, key, run_data) {
var disk_datas = [];
var data = JSON.parse(run_data);
data.data.forEach(function (v, i, a) {
Expand Down Expand Up @@ -42,16 +42,14 @@ function getStatValues(run, elem, key, run_data) {
}

function getStatKeys(run, container_id, mb, keys, run_data) {
var data = keys;
data.forEach(function (value, index, arr) {
for (let i = 0; i < all_run_keys.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is all_run_keys coming from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is found it src/html_files/utils.ts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is keys being used here? why not get all_run_keys as function parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keys is used below. all_run_keys is global. We don't have to get as a function parameter.

let value = all_run_keys[i];
var elem = document.createElement('div');
elem.id = `disk-stat-${run}-${value.name}`;
elem.id = `disk-stat-${run}-${value}`;
elem.style.float = "none";
addElemToNode(container_id, elem);
setTimeout(() => {
getStatValues(run, elem, value, run_data[value]);
}, 0);
})
emptyOrCallback(keys, getStatValues, elem, value, run_data);
}
}

function diskStats(mb: boolean) {
Expand Down
2 changes: 1 addition & 1 deletion src/html_files/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ <h3>Diff:</h3>
<script type="text/javascript" src="data/js/perf_profile.js"></script>
<script type="text/javascript" src="data/js/flamegraph.js"></script>
<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript" src="js/plotly.js"></script>
<script type="text/javascript" src="js/plotly.js" charset="utf-8"></script>
<script type="text/javascript" src="js/system_info.js"></script>
<script type="text/javascript" src="js/cpu_utilization.js"></script>
<script type="text/javascript" src="js/perf_profile.js"></script>
Expand Down
12 changes: 5 additions & 7 deletions src/html_files/meminfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,14 @@ function getMeminfo(elem, key, run_data) {
}

function getMeminfoKeys(run, container_id, keys, run_data) {
var data = keys;
data.forEach(function (value, index, arr) {
for (let i = 0; i < all_run_keys.length; i++) {
let value = all_run_keys[i];
var elem = document.createElement('div');
elem.id = `disk-stat-${run}-${value.name}`;
elem.id = `disk-stat-${run}-${value}`;
elem.style.float = "none";
addElemToNode(container_id, elem);
setTimeout(() => {
getMeminfo(elem, value, run_data[value]);
}, 0);
})
emptyOrCallback(keys, getMeminfo, elem, value, run_data);
}
}

function meminfo() {
Expand Down
15 changes: 5 additions & 10 deletions src/html_files/netstat.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
let got_netstat_data = false;

function getNetstatEntries(run, container_id, keys, run_data) {
var data = keys;
data.forEach(function (value, index, arr) {
for (let i = 0; i < all_run_keys.length; i++) {
let value = all_run_keys[i];
var elem = document.createElement('div');
elem.id = `netstat-${run}-${value}`;
elem.style.float = "none";
addElemToNode(container_id, elem);
setTimeout(() => {
getNetstatEntry(run, elem.id, value, run_data[value]);
}, 0);
})
emptyOrCallback(keys, getNetstatEntry, elem, value, run_data);
}
}

function getNetstatEntry(run, parent_id, key, run_data) {
function getNetstatEntry(elem, key, run_data) {
var data = JSON.parse(run_data);
var x_time = [];
var y_data = [];
data.data.forEach(function (value, index, arr) {
x_time.push(value.time.TimeDiff);
y_data.push(value.value);
});
var elem = document.createElement('div');
elem.style.float = "none";
addElemToNode(parent_id, elem);
var TESTER = elem;
var netstat_data: Partial<Plotly.PlotData> = {
x: x_time,
Expand Down
15 changes: 5 additions & 10 deletions src/html_files/perf_stat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ function getEvents(run, container_id, keys, run_data) {
no_data_div.innerHTML = "No data collected";
addElemToNode(container_id, no_data_div);
} else {
var data = keys;
data.forEach(function (value, index, arr) {
for (let i = 0; i < all_run_keys.length; i++) {
let value = all_run_keys[i];
var elem = document.createElement('div');
elem.id = `perfstat-${run}-${value}`;
elem.style.float = "none";
addElemToNode(container_id, elem);
setTimeout(() => {
getEvent(run, elem.id, value, run_data[value]);
}, 0);
})
emptyOrCallback(keys, getEvent, elem, value, run_data);
}
}
}

Expand All @@ -34,7 +32,7 @@ function addData(perfstat_data, stat, timediff) {
}
})
}
function getEvent(run, parent_id, key, run_data) {
function getEvent(elem, key, run_data) {
var data = JSON.parse(run_data);
var perfstat_datas = [];
data.data[0].cpus.forEach(function (value, index, arr) {
Expand All @@ -49,9 +47,6 @@ function getEvent(run, parent_id, key, run_data) {
addData(perfstat_datas, stat, value.time.TimeDiff);
})
});
var elem = document.createElement('div');
elem.style.float = "none";
addElemToNode(parent_id, elem);
var TESTER = elem;
var end_datas = [];
perfstat_datas.forEach(function (value, index, arr) {
Expand Down
33 changes: 33 additions & 0 deletions src/html_files/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ declare let netstat_raw_data;
declare let perf_profile_raw_data;
declare let flamegraph_raw_data;

let all_run_keys: Array<string> = new Array<string>();
let key_limits: Map<string, Limits> = new Map<string, Limits>();

function form_graph_limits(data) {
key_limits.clear();
all_run_keys.length = 0;
for (let i = 0; i < data.runs.length; i++) {
let key_values = data.runs[i]['key_values'];
for (let key in key_values) {
Expand All @@ -35,6 +37,18 @@ function form_graph_limits(data) {
}
}
}
for (let i = 0; i < data.runs.length; i++) {
let keys = data.runs[i]['keys'];
var prev_all_run_key_index = 0;
for (let j = 0; j < keys.length; j++) {
let key = keys[j];
if (all_run_keys.indexOf(key) == -1) {
all_run_keys.splice(prev_all_run_key_index, 0, key);
}
prev_all_run_key_index += 1;
}
}

for (let [key, value] of key_limits.entries()) {
let extra = (value.high - value.low) * 0.1;
value.high += extra;
Expand All @@ -47,6 +61,25 @@ function form_graph_limits(data) {
}
}
}

function emptyOrCallback(keys, callback, elem, key, run_data) {
if (keys.indexOf(key) == -1) {
setTimeout(() => {
emptyGraph(elem, key);
}, 0);
} else {
setTimeout(() => {
callback(elem, key, run_data[key]);
}, 0);
}
}
function emptyGraph(elem, key) {
var layout = {
title: `${key} (N/A)`,
}
Plotly.newPlot(elem, [], layout, { frameMargins: 0 });
}

class RunEntry {
run: string;
entries: Map<string, string>;
Expand Down
15 changes: 5 additions & 10 deletions src/html_files/vmstat.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
let got_vmstat_data = false;

function getEntries(run, container_id, keys, run_data) {
var data = keys;
data.forEach(function (value, index, arr) {
for (let i = 0; i < all_run_keys.length; i++) {
let value = all_run_keys[i];
var elem = document.createElement('div');
elem.id = `vmstat-${run}-${value}`;
elem.style.float = "none";
addElemToNode(container_id, elem);
setTimeout(() => {
getEntry(run, elem.id, value, run_data[value]);
}, 0);
})
emptyOrCallback(keys, getEntry, elem, value, run_data);
}
}

function getEntry(run, parent_id, key, run_data) {
function getEntry(elem, key, run_data) {
var data = JSON.parse(run_data);
var x_time = [];
var y_data = [];
data.data.forEach(function (value, index, arr) {
x_time.push(value.time.TimeDiff);
y_data.push(value.value);
});
var elem = document.createElement('div');
elem.style.float = "none";
addElemToNode(parent_id, elem);
var TESTER = elem;
var vmstat_data: Partial<Plotly.PlotData> = {
x: x_time,
Expand Down
Loading