improvements to frontend

This commit is contained in:
Pedro 2015-01-26 15:40:39 +01:00
parent b262cf9fe6
commit 7ceaf2e9c1
4 changed files with 42 additions and 13 deletions

View File

@ -39,18 +39,21 @@ HyriseConnector.prototype._formatPerformanceData = function(object) {
var totalTime = 0;
var queryTaskTime = 0;
var parseTime = 0;
$.each(performanceData, function(i, data) {
data.time_ms = data.endTime - data.startTime;
totalTime += data.time_ms;
if (data.name === 'SQLQueryTask') queryTaskTime += data.time_ms;
if (data.name === 'RequestParseTask') parseTime += data.time_ms;
});
object.performanceData = {
totalTime: totalTime,
queryTaskTime: queryTaskTime,
operators: performanceData
parseTime: parseTime,
operators: performanceData,
}
};
@ -62,6 +65,7 @@ HyriseConnector.prototype.benchmarkSQL = function(query, numRuns, callback) {
var result = {
totalTime: 0,
queryTaskTime: 0,
parseTime: 0,
numRuns: allData.length,
operators: []
};
@ -72,6 +76,7 @@ HyriseConnector.prototype.benchmarkSQL = function(query, numRuns, callback) {
var perfData = run.performanceData;
result.totalTime += perfData.totalTime;
result.queryTaskTime += perfData.queryTaskTime;
result.parseTime += perfData.parseTime;
$.each(perfData.operators, function(i, data) {
if (!(data.id in operatorMap)) {
@ -89,6 +94,7 @@ HyriseConnector.prototype.benchmarkSQL = function(query, numRuns, callback) {
// Calc average and Transform into array
result.totalTime /= result.numRuns;
result.queryTaskTime /= result.numRuns;
result.parseTime /= result.numRuns;
$.each(operatorMap, function(id, data) {
data.duration /= result.numRuns;
@ -103,17 +109,21 @@ HyriseConnector.prototype.benchmarkSQL = function(query, numRuns, callback) {
}
var allData = [];
var n = 0;
var num_completed = 0;
function __run() {
++n;
self.executeSQL(query, function(result) {
allData.push(result);
// Run again or return aggregated Data
if (n < numRuns) __run();
else __aggregateData(allData);
num_completed++;
if (num_completed == numRuns) __aggregateData(allData);
});
}
for (var i = 0; i < numRuns; ++i) {
__run();
}
__run();
};

View File

@ -58,7 +58,8 @@
<div class="row">
<div class="col-sm-12">
<!-- View: Performance Data -->
<h3>Performance Data (<span id="timeTotal">?</span>ms)</h3>
<h3>Performance Data</h3>
<h4 id="timeInfo"></h4>
<table id="performanceDataTable" class="table table-bordered table-striped table-hover">
<thead>
@ -66,9 +67,9 @@
<th data-key="id">ID</th>
<th data-key="name">Name</th>
<th data-key="duration">Duration</th>
<!-- <th>Start Time</th> -->
<!-- <th>End Time</th> -->
<th data-key="time_ms">Time (ms)</th>
<th data-key="startTime">Start Time</th>
<th data-key="endTime">End Time</th>
</tr>
</thead>
<tbody></tbody>

View File

@ -16,6 +16,7 @@ table {
font-size: 14px;
}
.content {
width: 90%;
margin: auto;
@ -26,4 +27,12 @@ textarea#queryInput {
font-family: 'Monospace';
height: 500px;
resize: none;
}
h1, h2, h3, h4, h5, h6 {
margin-top: 0px;
}
h4 {
font-size: 14px;
}

View File

@ -190,12 +190,16 @@ function UpdateResultTable(result) {
function UpdatePerformanceData(performanceData) {
var table = document.querySelector('#performanceDataTable');
$('#timeTotal').html(performanceData.totalTime.toFixed(2));
var timeStrings = [
(performanceData.queryTaskTime + performanceData.parseTime).toFixed(3),
performanceData.queryTaskTime.toFixed(3),
performanceData.parseTime.toFixed(3),
performanceData.totalTime.toFixed(3),
]
var timeInfo = + ','
$('#timeInfo').html(timeStrings.join(','));
// Sort and insert into table
if (!table._sortKey) table._sortKey = 'startTime';
if (!('_asc') in table) table._asc = true;
var tableData = performanceData.operators;
table._data = tableData;
SortTableData(table);
@ -214,13 +218,18 @@ function InsertPerformanceData(performanceData) {
tr.append(CreateElement('td', data.name));
tr.append(CreateElement('td', data.duration));
tr.append(CreateElement('td', data.time_ms.toFixed(6)));
tr.append(CreateElement('td', data.startTime));
tr.append(CreateElement('td', data.endTime));
tbody.append(tr);
});
}
function SortTableData(table) {
if (!table._sortKey) table._sortKey = 'startTime';
if (!('_asc') in table) table._asc = true;
var key = table._sortKey;
var sign = (table._asc) ? 1 : -1;
var sign = (table._asc) ? -1 : 1;
table._data.sort(function(a, b) {
if (a[key].localeCompare) return sign * a[key].localeCompare(b[key]);
return sign * (a[key] - b[key]);