summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e55597a)
raw | patch | inline | side by side (parent: e55597a)
author | Nikhil Devshatwar <nikhil.nd@ti.com> | |
Sun, 9 Feb 2020 14:22:31 +0000 (19:52 +0530) | ||
committer | Nikhil Devshatwar <nikhil.nd@ti.com> | |
Mon, 10 Feb 2020 10:44:51 +0000 (16:14 +0530) |
* Rename variables, move functions to reorganize
* Fix unitTest
Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
* Fix unitTest
Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
statistics/Stats.html | patch | blob | history |
diff --git a/statistics/Stats.html b/statistics/Stats.html
index 748bfdd823554bfd72ffcd882674e19617da579d..556ac8fd17bde4a45f381a937b9e05f104686243 100644 (file)
--- a/statistics/Stats.html
+++ b/statistics/Stats.html
<script>
var debug = document.getElementById("debug")
- var bargraphs = {};
+ var linegraphs = {};
var indicators = {};
var connection;
var unitTestStop = 0;
}
return mergeDeep(target, ...sources);
}
+
+ function convert_units_to_absolute(input) {
+ var regex = /([0-9]+)([KMG])bps/;
+ var conversion = { "K": 1000, "M": 1000000, "G": 1000000000 };
+ output = []
+ //console.log("input = " + input);
+ for (value of input) {
+ match = regex.exec(value);
+ if (match) {
+ value = match[1] * conversion[match[2]];
+ }
+ output.push(value);
+ }
+ //console.log("output = " + output);
+ return output;
+ }
+
///////////////////////////////////////////////////////////////////////////
- function barGraphCreate(id, caption, traces, num_samples, custom_layout) {
+ function linegraphCreate(id, caption, traces, num_samples, custom_layout) {
var graph = new Object();
graph.id = id;
graph.num_samples = num_samples;
},
};
- mergeDeep(layout, custom_layout);
+ if (custom_layout) {
+ mergeDeep(layout, custom_layout);
+ }
Plotly.plot(graph.id, data, layout);
return graph;
}
- function barGraphUpdate(graph, data) {
+ function linegraphUpdate(graph, data) {
var indices = [];
for (i = 0; i < data.length; i++) {
indices.push(i);
}
}
- function handle_bargraph(values, id, name, label, custom_layout) {
+ function handle_linegraph(values, id, name, label, custom_layout) {
var traces = [];
var data = [];
var x;
- if (bargraphs[id] == null) {
+ if (linegraphs[id] == null) {
for (i = 0; i < parseInt(values[1]); i++) {
type = values[2 + i * 2];
- console.log("Adding bargraph trace for " + id + ":" + type);
+ console.log("Adding linegraph trace for " + id + ":" + type);
traces.push({
y: [0],
name: type,
type: 'line',
});
}
- bargraphs[id] = barGraphCreate(id, label, traces, 100, custom_layout);
+ linegraphs[id] = linegraphCreate(id, label, traces, 100, custom_layout);
add_toggle_button(id, name);
} else {
for (i = 0; i < parseInt(values[1]); i++) {
curVal = values[3 + i * 2];
data.push([parseInt(curVal),]);
}
- barGraphUpdate(bargraphs[id], data);
+ linegraphUpdate(linegraphs[id], data);
}
}
connection.close();
}
- bargraphs = {};
+ linegraphs = {};
indicators = {};
document.getElementById('stats_area').innerHTML = "";
d("Waiting for connection...");
}
- function convert_units_to_absolute(input) {
- var regex = /([0-9]+)([KMG])bps/;
- var conversion = { "K": 1000, "M": 1000000, "G": 1000000000 };
- output = []
- console.log("input = " + input);
- for (value of input) {
- match = regex.exec(value);
- if (match) {
- value = match[1] * conversion[match[2]];
- }
- output.push(value);
- }
- console.log("output = " + output);
- return output;
- }
-
function handle_message(event) {
//console.log("Received data: " + event.data);
values = event.data.split(" ");
range: [0, 100],
},
};
- handle_bargraph(values, 'cpuload', "CPU load", "CPUload (%)", layout);
+ handle_linegraph(values, 'cpuload', "CPU load", "CPUload (%)", layout);
break;
case "WS-ddrbw:":
layout = {
range: [0, 10000],
},
};
- handle_bargraph(values, 'ddrbw', "DDR Bandwidth", "DDR bandwidth (MBps)", layout);
+ handle_linegraph(values, 'ddrbw', "DDR Bandwidth", "DDR bandwidth (MBps)", layout);
break;
case "WS-ethfw-bw:":
values = convert_units_to_absolute(values);
type: "log",
},
};
- handle_bargraph(values, 'ethfwbw', "Ethernet bandwidth", "Ethernet bandwidth", layout);
+ handle_linegraph(values, 'ethfwbw', "Ethernet bandwidth", "Ethernet bandwidth", layout);
break;
case "WS-cluster-fps:":
handle_indicator(values, 'cluster-fps', "Cluster FPS", "Cluster FPS", 60)
setTimeout(test_random_data, 300);
}
- //test_random_data();
+ document.getElementById('ipaddr').value = "172.24.190.9";
+ test_random_data();
}
///////////////////////////////////////////////////////////////////////////
reset();
- //document.getElementById('ipaddr').value = "172.24.190.9";
- //unitTest();
+
+ unitTest();
</script>