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'] ...@@ -11,7 +11,7 @@ const ctrl_shift_shortcuts = ['v', 'h', 'V', 'H']
const shortcut_triggers = ['Shift', 'Control'] const shortcut_triggers = ['Shift', 'Control']
let shortcut_flag = false let shortcut_flag = false
const csv_header = ['filename', 'speed', 'avg_speed']; const csv_header = ['record_no', 'filename', 'speed', 'eoe_timestamp', 'avg_speed'];
const startMetricCapture = () => { const startMetricCapture = () => {
// reset key strokes // reset key strokes
...@@ -88,13 +88,14 @@ const showMetricCapture = () => { ...@@ -88,13 +88,14 @@ const showMetricCapture = () => {
setTimeout(showMetricCapture, 1000); setTimeout(showMetricCapture, 1000);
} }
const saveMetrics = (metrics) => { const saveMetrics = (metrics, eoe_ts) => {
try try
{ {
eoe_ts = formatDate(eoe_ts);
let rows = new Array(); let rows = new Array();
if (sessionStorage.getItem('csv') === null) { if (sessionStorage.getItem('csv') === null) {
rows.push(csv_header); 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 { } else {
rows = JSON.parse(sessionStorage.getItem('csv')); rows = JSON.parse(sessionStorage.getItem('csv'));
let size = rows.length - 1; let size = rows.length - 1;
...@@ -103,7 +104,7 @@ const saveMetrics = (metrics) => { ...@@ -103,7 +104,7 @@ const saveMetrics = (metrics) => {
let newAvg = ((avg * size) + metrics.rate) / (size + 1); 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( var myFile = new File(
...@@ -121,7 +122,7 @@ const saveMetrics = (metrics) => { ...@@ -121,7 +122,7 @@ const saveMetrics = (metrics) => {
sessionStorage.setItem('csv', JSON.stringify(rows)); sessionStorage.setItem('csv', JSON.stringify(rows));
} catch(Err){ } catch(Err){
alert("Error: " + Err.description); console.log("Error: " + Err.description);
} }
} }
...@@ -138,4 +139,8 @@ const pauseMetricCapture = () => { ...@@ -138,4 +139,8 @@ const pauseMetricCapture = () => {
const unpauseMetricCapture = () => { const unpauseMetricCapture = () => {
time_pause_spent += (Date.now() - time_pause) / 1000; time_pause_spent += (Date.now() - time_pause) / 1000;
time_pause = 0; time_pause = 0;
}
const formatDate = (date) => {
return date.replace(",", "");
} }
\ No newline at end of file
const submitForm = (e) => { const submitForm = (e) => {
try { try {
let eoe_ts = new Date().toLocaleString();
const Form = Settings.SrcElement(e); const Form = Settings.SrcElement(e);
const { elements } = Form const { elements } = Form
let error = false let error = false
...@@ -39,6 +40,7 @@ const submitForm = (e) => { ...@@ -39,6 +40,7 @@ const submitForm = (e) => {
const metrics = stopMetricCapture(); const metrics = stopMetricCapture();
WriteForm(e, metrics); WriteForm(e, metrics);
saveMetrics(metrics); saveMetrics(metrics);
saveMetrics(metrics, eoe_ts);
return true return true
} }
} catch(err) { } 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