Skip to content

Commit

Permalink
Update kernel config & sysctl tabs
Browse files Browse the repository at this point in the history
Make Diff 'Yes' the default for Kernel Config and Sysctl.
  • Loading branch information
janaknat committed Oct 9, 2023
1 parent 6b3ae13 commit 4219096
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 132 deletions.
4 changes: 2 additions & 2 deletions src/html_files/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ <h3>Hide zero, N/A graphs:</h3>
<div id="kernel_config" class="tabcontent">
<div>
<h3>Diff:</h3>
<input type="radio" class="kernel-button" id="kernel_diff_yes" name="kernelDiff">Yes</button>
<input type="radio" class="kernel-button" id="kernel_diff_yes" name="kernelDiff" checked>Yes</button>
<input type="radio" class="kernel-button" id="kernel_diff_no" name="kernelDiff">No</button>
</div>
<div id="kernel-config-runs"></div>
</div>
<div id="sysctl" class="tabcontent">
<div>
<h3>Diff:</h3>
<input type="radio" class="sysctl-button" id="sysctl_diff_yes" name="sysctlDiff">Yes</button>
<input type="radio" class="sysctl-button" id="sysctl_diff_yes" name="sysctlDiff" checked>Yes</button>
<input type="radio" class="sysctl-button" id="sysctl_diff_no" name="sysctlDiff">No</button>
</div>
<div id="sysctl-data-runs"></div>
Expand Down
22 changes: 16 additions & 6 deletions src/html_files/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,28 @@ function openData(evt: Event, elem: HTMLButtonElement) {
if (tabName == "processes") {
processes();
}
if (tabName == "kernel_config") {
kernelConfig(false);
}
if (tabName == "sysctl") {
sysctl(false);
}
if (tabName == "interrupts") {
interrupts();
}
if (tabName == "perfstat") {
perfStat();
}
if (tabName == "kernel_config") {
let id = document.querySelector('input[name="kernelDiff"]:checked').id;
if (id == "kernel_diff_yes") {
kernelConfig(true);
} else {
kernelConfig(false);
}
}
if (tabName == "sysctl") {
let id = document.querySelector('input[name="sysctlDiff"]:checked').id;
if (id == "sysctl_diff_yes") {
sysctl(true);
} else {
sysctl(false);
}
}
if (tabName == "meminfo") {
let id = document.querySelector('input[name="meminfoHide"]:checked').id;
if (id == "meminfo_hide_yes") {
Expand Down
137 changes: 69 additions & 68 deletions src/html_files/kernel_config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
let got_kernel_config_data = false;
let current_diff_status = false;
let current_kernel_diff_status = false;

var kernel_config_runs: Map<string, RunEntry> = new Map<string, RunEntry>();
var kernel_config_run_names: Array<string> = [];
var kernel_config_common_keys: Array<string> = [];

function createEntries(container_id, values, level, run, store) {
function createEntries(container_id, values, level, run) {
values?.forEach(function(value, index, arr) {
for (var prop in value) {
if ('value' in value[prop]) {
Expand All @@ -14,13 +14,6 @@ function createEntries(container_id, values, level, run, store) {
dt.style.fontWeight = "normal";
dt.innerHTML = `${value[prop].name} = ${value[prop].value}`;
addElemToNode(container_id, dt);
if (store) {
let run_entry = kernel_config_runs.get(run);
let title = value[prop].name;
let title_value = value[prop].value;
run_entry.entries.set(title, title_value);
run_entry.keys.push(title);
}
} else {
var dl = document.createElement('dl');
dl.style.textIndent = `${level * 5}%`;
Expand All @@ -29,91 +22,102 @@ function createEntries(container_id, values, level, run, store) {
dl.id = `${run}-${value[prop].name}`;
addElemToNode(container_id, dl);
setTimeout(() => {
createEntries(dl.id, value[prop].entries, level + 1, run, store);
createEntries(dl.id, value[prop].entries, level + 1, run);
}, 0);
}
}
});
}

function getKernelConfig(run, container_id, run_data, diff) {
function form_kernel_data(run, run_data) {
kernel_config_run_names.push(run);
var run_entry = new RunEntry();
run_entry.run = run;
run_entry.entries = new Map<string, string>();
run_entry.keys = new Array();
run_entry.diff_keys = new Array();
run_entry.raw_entries = run_data;
kernel_config_runs.set(run, run_entry);
var data = JSON.parse(run_data);
let data = JSON.parse(run_entry.raw_entries['key_values']['values']);
data.forEach(function (value, index, arr) {
value.entries?.forEach(function(value, index, arr) {
for (var prop in value) {
if ('value' in value[prop]) {
let run_entry = kernel_config_runs.get(run);
let title = value[prop].name;
let title_value = value[prop].value;
run_entry.entries.set(title, title_value);
run_entry.keys.push(title);
}
}
});
});
}

function kernelConfigNoDiff(run, container_id) {
let run_entry = kernel_config_runs.get(run);
let data = JSON.parse(run_entry.raw_entries['key_values']['values']);
var dl = document.createElement('dl');
dl.id = `${run}-dl-kernel-config`;
dl.style.float = "none";
var dl_id = dl.id;
addElemToNode(container_id, dl);
kernel_config_runs.get(run).raw_entries = run_data;
data.forEach(function (value, index, arr) {
var dt = document.createElement('dl');
dt.id = `${run}-${value.name}`;
dt.id = `${run_entry.run}-${value.name}`;
dt.style.fontWeight = "bold";
dt.innerHTML = value.name;
addElemToNode(dl_id, dt);
createEntries(dt.id, value.entries, 1, run, true);
createEntries(dt.id, value.entries, 1, run_entry.run);
});
}

function redoKernelConfig(diff) {
kernel_config_run_names.forEach(function (value, index, array) {
var agg_id = `${value}-kernel-config-div`;
clearElements(agg_id);
var dl = document.createElement('dl');
dl.id = `${value}-dl-kernel-config`;
dl.style.float = "none";
var dl_id = dl.id;
addElemToNode(agg_id, dl);
let run_entry = kernel_config_runs.get(value);
if (diff) {
var h3_common = document.createElement('h3');
h3_common.innerHTML = 'Common Keys';
h3_common.style.textAlign = "center";
addElemToNode(dl_id, h3_common);
for (let i = 0; i < kernel_config_common_keys.length; i++) {
if (isDiffAcrossRuns(kernel_config_common_keys[i], kernel_config_run_names, kernel_config_runs)) {
let e = run_entry.entries.get(kernel_config_common_keys[i]);
createNode(kernel_config_common_keys[i], e, dl_id);
}
}
var h3_diff = document.createElement('h3');
h3_diff.innerHTML = 'Different Keys';
h3_diff.style.textAlign = "center";
addElemToNode(dl_id, h3_diff);
for (let i = 0; i < run_entry.diff_keys.length; i++) {
let key = run_entry.diff_keys[i];
let e = run_entry.entries.get(key);
createNode(key, e, dl_id);
}
} else {
let data = JSON.parse(run_entry.raw_entries);
data.forEach(function (value, index, arr) {
var dt = document.createElement('dl');
dt.id = `${run_entry.run}-${value.name}`;
dt.style.fontWeight = "bold";
dt.innerHTML = value.name;
addElemToNode(dl_id, dt);
createEntries(dt.id, value.entries, 1, run_entry.run, false);
});
function kernelConfigDiff(value, container_id) {
var dl = document.createElement('dl');
dl.id = `${value}-dl-kernel-config`;
dl.style.float = "none";
var dl_id = dl.id;
addElemToNode(container_id, dl);
let run_entry = kernel_config_runs.get(value);
var h3_common = document.createElement('h3');
h3_common.innerHTML = 'Common Keys';
h3_common.style.textAlign = "center";
addElemToNode(dl_id, h3_common);
for (let i = 0; i < kernel_config_common_keys.length; i++) {
if (isDiffAcrossRuns(kernel_config_common_keys[i], kernel_config_run_names, kernel_config_runs)) {
let e = run_entry.entries.get(kernel_config_common_keys[i]);
createNode(kernel_config_common_keys[i], e, dl_id);
}
})
}
var h3_diff = document.createElement('h3');
h3_diff.innerHTML = 'Different Keys';
h3_diff.style.textAlign = "center";
addElemToNode(dl_id, h3_diff);
for (let i = 0; i < run_entry.diff_keys.length; i++) {
let key = run_entry.diff_keys[i];
let e = run_entry.entries.get(key);
createNode(key, e, dl_id);
}
}

function kernelConfig(diff: boolean) {
if (got_kernel_config_data) {
if (current_diff_status != diff) {
current_diff_status = diff;
redoKernelConfig(diff);
}
if (got_kernel_config_data && current_kernel_diff_status == diff) {
return;
}
current_kernel_diff_status = diff;
var data = runs_raw;
if (!got_kernel_config_data) {
data.forEach(function (value, index, arr) {
let this_run_data;
for (let i = 0; i < kernel_config_raw_data['runs'].length; i++) {
if (kernel_config_raw_data['runs'][i]['name'] == value) {
this_run_data = kernel_config_raw_data['runs'][i];
form_kernel_data(value, this_run_data);
}
}
})
split_keys(kernel_config_runs, kernel_config_common_keys);
}
var float_style = "none";
if (data.length > 1) {
float_style = "left";
Expand All @@ -123,7 +127,6 @@ function kernelConfig(diff: boolean) {
data.forEach(function (value, index, arr) {
// Run div
var run_div = document.createElement('div');
let this_run_data;
run_div.id = `${value}-kernel-config`;
run_div.style.float = float_style;
run_div.style.width = `${run_width}%`;
Expand All @@ -140,13 +143,11 @@ function kernelConfig(diff: boolean) {
var agg_elem = document.createElement('div');
agg_elem.id = `${value}-kernel-config-div`;
addElemToNode(run_node_id, agg_elem);
for (let i = 0; i < kernel_config_raw_data['runs'].length; i++) {
if (kernel_config_raw_data['runs'][i]['name'] == value) {
this_run_data = kernel_config_raw_data['runs'][i];
}
if (current_kernel_diff_status) {
kernelConfigDiff(value, agg_elem.id);
} else {
kernelConfigNoDiff(value, agg_elem.id);
}
getKernelConfig(value, agg_elem.id, this_run_data['key_values']['values'], diff);
})
split_keys(kernel_config_runs, kernel_config_common_keys);
got_kernel_config_data = true;
}
Loading

0 comments on commit 4219096

Please sign in to comment.