diff --git a/src/html_files/index.html b/src/html_files/index.html index 2beab100..00101d97 100644 --- a/src/html_files/index.html +++ b/src/html_files/index.html @@ -52,7 +52,7 @@

Hide zero, N/A graphs:

Diff:

- Yes + Yes No
@@ -60,7 +60,7 @@

Diff:

Diff:

- Yes + Yes No
diff --git a/src/html_files/index.ts b/src/html_files/index.ts index 69aa831c..ef86f909 100644 --- a/src/html_files/index.ts +++ b/src/html_files/index.ts @@ -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") { diff --git a/src/html_files/kernel_config.ts b/src/html_files/kernel_config.ts index 3f745261..6f373a9b 100644 --- a/src/html_files/kernel_config.ts +++ b/src/html_files/kernel_config.ts @@ -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 = new Map(); var kernel_config_run_names: Array = []; var kernel_config_common_keys: Array = []; -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]) { @@ -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}%`; @@ -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(); 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"; @@ -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}%`; @@ -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; } diff --git a/src/html_files/sysctl.ts b/src/html_files/sysctl.ts index 845dba88..ac22e6b4 100644 --- a/src/html_files/sysctl.ts +++ b/src/html_files/sysctl.ts @@ -5,8 +5,7 @@ var sysctl_runs: Map = new Map(); var sysctl_run_names: Array = []; var sysctl_common_keys: Array = []; -function getSysctl(run, container_id, run_data) { - const http = new XMLHttpRequest(); +function form_sysctl_data(run, run_data) { sysctl_run_names.push(run); var run_entry = new RunEntry(); run_entry.run = run; @@ -14,69 +13,75 @@ function getSysctl(run, container_id, run_data) { run_entry.keys = new Array(); run_entry.diff_keys = new Array(); sysctl_runs.set(run, run_entry); - var data = JSON.parse(run_data); - var dl = document.createElement('dl'); - dl.id = `${run}-dl-sysctl-data`; - dl.style.float = "none"; - var dl_id = dl.id; - addElemToNode(container_id, dl); + var data = JSON.parse(run_data['key_values']['values']); for (var key in data) { var value = data[key]; let run_entry = sysctl_runs.get(run); run_entry.entries.set(key, value); run_entry.keys.push(key); + } +} +function sysctlNoDiff(run, container_id) { + var dl = document.createElement('dl'); + dl.id = `${run}-dl-sysctl-data`; + dl.style.float = "none"; + var dl_id = dl.id; + addElemToNode(container_id, dl); + let run_entry = sysctl_runs.get(run); + for (let [key, value] of run_entry.entries) { createNode(key, value, dl_id); } } -function redoSysctl(diff: boolean) { - sysctl_run_names.forEach(function (value, index, array) { - var agg_id = `${value}-sysctl-data-div`; - clearElements(agg_id); - var dl = document.createElement('dl'); - dl.id = `${value}-dl-sysctl-data`; - dl.style.float = "none"; - var dl_id = dl.id; - addElemToNode(agg_id, dl); - let run_entry = sysctl_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 < sysctl_common_keys.length; i++) { - if (isDiffAcrossRuns(sysctl_common_keys[i], sysctl_run_names, sysctl_runs)) { - let e = run_entry.entries.get(sysctl_common_keys[i]); - createNode(sysctl_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 { - for (let [key, value] of run_entry.entries) { - createNode(key, value, dl_id); - } +function sysctlDiff(value) { + var agg_id = `${value}-sysctl-data-div`; + clearElements(agg_id); + var dl = document.createElement('dl'); + dl.id = `${value}-dl-sysctl-data`; + dl.style.float = "none"; + var dl_id = dl.id; + addElemToNode(agg_id, dl); + let run_entry = sysctl_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 < sysctl_common_keys.length; i++) { + if (isDiffAcrossRuns(sysctl_common_keys[i], sysctl_run_names, sysctl_runs)) { + let e = run_entry.entries.get(sysctl_common_keys[i]); + createNode(sysctl_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 sysctl(diff: boolean) { - if (got_sysctl_data) { - if (current_sysctl_diff_status != diff) { - current_sysctl_diff_status = diff; - redoSysctl(diff); - } + if (got_sysctl_data && current_sysctl_diff_status == diff) { return; } - + current_sysctl_diff_status = diff; var data = runs_raw; + if (!got_sysctl_data) { + data.forEach(function (value, index, arr) { + let this_run_data; + for (let i = 0; i < sysctl_raw_data['runs'].length; i++) { + if (sysctl_raw_data['runs'][i]['name'] == value) { + this_run_data = sysctl_raw_data['runs'][i]; + form_sysctl_data(value, this_run_data); + } + } + }); + split_keys(sysctl_runs, sysctl_common_keys); + } + var float_style = "none"; if (data.length > 1) { float_style = "left"; @@ -86,7 +91,6 @@ function sysctl(diff: boolean) { data.forEach(function (value, index, arr) { // Run div var run_div = document.createElement('div'); - let this_run_data; run_div.id = `${value}-sysctl-data`; run_div.style.float = float_style; run_div.style.width = `${run_width}%`; @@ -103,13 +107,12 @@ function sysctl(diff: boolean) { var agg_elem = document.createElement('div'); agg_elem.id = `${value}-sysctl-data-div`; addElemToNode(run_node_id, agg_elem); - for (let i = 0; i < sysctl_raw_data['runs'].length; i++) { - if (sysctl_raw_data['runs'][i]['name'] == value) { - this_run_data = sysctl_raw_data['runs'][i]; - } + + if (current_sysctl_diff_status) { + sysctlDiff(value); + } else { + sysctlNoDiff(value, agg_elem.id); } - getSysctl(value, agg_elem.id, this_run_data['key_values']['values']); }) - split_keys(sysctl_runs, sysctl_common_keys); got_sysctl_data = true; } \ No newline at end of file