Commit 862870cc by Daniel Bawag

WG-70 - Modified the performance output CSV

parent bbacabcc
......@@ -11,7 +11,7 @@ const ctrl_shift_shortcuts = ['v', 'h', 'V', 'H']
const shortcut_triggers = ['Shift', 'Control']
let shortcut_flag = false
const csv_header = ['filename', 'speed', 'avg_speed'];
const csv_header = ['record_no', 'filename', 'speed', 'eoe_timestamp', 'avg_speed'];
const startMetricCapture = () => {
// reset key strokes
......@@ -88,13 +88,14 @@ const showMetricCapture = () => {
setTimeout(showMetricCapture, 1000);
}
const saveMetrics = (metrics) => {
const saveMetrics = (metrics, eoe_ts) => {
try
{
eoe_ts = formatDate(eoe_ts);
let rows = new Array();
if (sessionStorage.getItem('csv') === null) {
rows.push(csv_header);
rows.push([escapeCSV(File_Path.replace(/^.*[\\\/]/, '')), metrics.rate, metrics.rate]);
rows.push([1, escapeCSV(File_Path.replace(/^.*[\\\/]/, '')), metrics.rate, eoe_ts, metrics.rate]);
} else {
rows = JSON.parse(sessionStorage.getItem('csv'));
let size = rows.length - 1;
......@@ -103,7 +104,7 @@ const saveMetrics = (metrics) => {
let newAvg = ((avg * size) + metrics.rate) / (size + 1);
rows.push([escapeCSV(File_Path.replace(/^.*[\\\/]/, '')), metrics.rate, newAvg]);
rows.push([(size + 1), escapeCSV(File_Path.replace(/^.*[\\\/]/, '')), metrics.rate, eoe_ts, newAvg]);
}
var myFile = new File(
......@@ -121,7 +122,7 @@ const saveMetrics = (metrics) => {
sessionStorage.setItem('csv', JSON.stringify(rows));
} catch(Err){
alert("Error: " + Err.description);
console.log("Error: " + Err.description);
}
}
......@@ -138,4 +139,8 @@ const pauseMetricCapture = () => {
const unpauseMetricCapture = () => {
time_pause_spent += (Date.now() - time_pause) / 1000;
time_pause = 0;
}
const formatDate = (date) => {
return date.replace(",", "");
}
\ No newline at end of file
const submitForm = (e) => {
try {
let eoe_ts = new Date().toLocaleString();
const Form = Settings.SrcElement(e);
const { elements } = Form
let error = false
......@@ -39,6 +40,7 @@ const submitForm = (e) => {
const metrics = stopMetricCapture();
WriteForm(e, metrics);
saveMetrics(metrics);
saveMetrics(metrics, eoe_ts);
return true
}
} catch(err) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment