mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-21 10:37:18 +02:00
[ui] StatViewer: compatibility with previous "statistics" files
This commit is contained in:
parent
4d7ea32721
commit
8f630d5c09
1 changed files with 23 additions and 20 deletions
|
@ -73,6 +73,13 @@ Item {
|
||||||
readSourceFile()
|
readSourceFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPropertyWithDefault(prop, name, defaultValue) {
|
||||||
|
if(prop.hasOwnProperty(name)) {
|
||||||
|
return prop[name];
|
||||||
|
}
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: reloadTimer
|
id: reloadTimer
|
||||||
interval: root.deltaTime * 60000; running: true; repeat: false
|
interval: root.deltaTime * 60000; running: true; repeat: false
|
||||||
|
@ -92,10 +99,8 @@ Item {
|
||||||
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status == 200) {
|
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status == 200) {
|
||||||
|
|
||||||
if(sourceModified === undefined || sourceModified < xhr.getResponseHeader('Last-Modified')) {
|
if(sourceModified === undefined || sourceModified < xhr.getResponseHeader('Last-Modified')) {
|
||||||
var jsonObject;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
jsonObject = JSON.parse(xhr.responseText);
|
root.jsonObject = JSON.parse(xhr.responseText);
|
||||||
}
|
}
|
||||||
catch(exc)
|
catch(exc)
|
||||||
{
|
{
|
||||||
|
@ -103,7 +108,6 @@ Item {
|
||||||
root.jsonObject = {};
|
root.jsonObject = {};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
root.jsonObject = jsonObject;
|
|
||||||
resetCharts();
|
resetCharts();
|
||||||
sourceModified = xhr.getResponseHeader('Last-Modified')
|
sourceModified = xhr.getResponseHeader('Last-Modified')
|
||||||
root.createCharts();
|
root.createCharts();
|
||||||
|
@ -122,7 +126,7 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function createCharts() {
|
function createCharts() {
|
||||||
root.deltaTime = jsonObject.interval / 60.0;
|
root.deltaTime = getPropertyWithDefault(jsonObject, 'interval', 30) / 60.0;
|
||||||
initCpuChart()
|
initCpuChart()
|
||||||
initRamChart()
|
initRamChart()
|
||||||
initGpuChart()
|
initGpuChart()
|
||||||
|
@ -139,7 +143,7 @@ Item {
|
||||||
var categoryCount = 0
|
var categoryCount = 0
|
||||||
var category
|
var category
|
||||||
do {
|
do {
|
||||||
category = root.jsonObject.computer.curves["cpuUsage." + categoryCount]
|
category = jsonObject.computer.curves["cpuUsage." + categoryCount]
|
||||||
if(category !== undefined) {
|
if(category !== undefined) {
|
||||||
categories.push(category)
|
categories.push(category)
|
||||||
categoryCount++
|
categoryCount++
|
||||||
|
@ -149,7 +153,7 @@ Item {
|
||||||
var nbCores = categories.length
|
var nbCores = categories.length
|
||||||
root.nbCores = nbCores
|
root.nbCores = nbCores
|
||||||
|
|
||||||
root.cpuFrequency = jsonObject.computer.cpuFreq
|
root.cpuFrequency = getPropertyWithDefault(jsonObject.computer, 'cpuFreq', -1)
|
||||||
|
|
||||||
root.nbReads = categories[0].length-1
|
root.nbReads = categories[0].length-1
|
||||||
|
|
||||||
|
@ -202,37 +206,37 @@ Item {
|
||||||
**************************/
|
**************************/
|
||||||
|
|
||||||
function initRamChart() {
|
function initRamChart() {
|
||||||
root.ramTotal = jsonObject.computer.ramTotal
|
|
||||||
|
|
||||||
var ram = jsonObject.computer.curves.ramUsage
|
root.ramTotal = getPropertyWithDefault(jsonObject.computer, 'ramTotal', 1)
|
||||||
|
|
||||||
|
var ram = getPropertyWithDefault(jsonObject.computer.curves, 'ramUsage', -1)
|
||||||
|
|
||||||
var ramSerie = ramChart.createSeries(ChartView.SeriesTypeLine, "RAM: " + root.ramTotal + "GB", valueAxisX2, valueAxisRam)
|
var ramSerie = ramChart.createSeries(ChartView.SeriesTypeLine, "RAM: " + root.ramTotal + "GB", valueAxisX2, valueAxisRam)
|
||||||
|
|
||||||
if(ram.length === 1) {
|
if(ram.length === 1) {
|
||||||
ramSerie.append(0, ram[0] / 100 * root.ramTotal)
|
// Create 2 entries if we have only one input value to create a segment that can be display
|
||||||
ramSerie.append(root.deltaTime, ram[0] / 100 * root.ramTotal)
|
ramSerie.append(0, ram[0])
|
||||||
|
ramSerie.append(root.deltaTime, ram[0])
|
||||||
} else {
|
} else {
|
||||||
for(var i = 0; i < ram.length; i++) {
|
for(var i = 0; i < ram.length; i++) {
|
||||||
ramSerie.append(i * root.deltaTime, ram[i] / 100 * root.ramTotal)
|
ramSerie.append(i * root.deltaTime, ram[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ramSerie.color = colors[10]
|
ramSerie.color = colors[10]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**************************
|
/**************************
|
||||||
*** GPU ***
|
*** GPU ***
|
||||||
**************************/
|
**************************/
|
||||||
|
|
||||||
function initGpuChart() {
|
function initGpuChart() {
|
||||||
root.gpuTotalMemory = jsonObject.computer.gpuMemoryTotal
|
root.gpuTotalMemory = getPropertyWithDefault(jsonObject.computer, 'gpuMemoryTotal', 0)
|
||||||
root.gpuName = jsonObject.computer.gpuName
|
root.gpuName = getPropertyWithDefault(jsonObject.computer, 'gpuName', '')
|
||||||
|
|
||||||
var gpuUsedMemory = jsonObject.computer.curves.gpuMemoryUsed
|
var gpuUsedMemory = getPropertyWithDefault(jsonObject.computer.curves, 'gpuMemoryUsed', 0)
|
||||||
var gpuUsed = jsonObject.computer.curves.gpuUsed
|
var gpuUsed = getPropertyWithDefault(jsonObject.computer.curves, 'gpuUsed', 0)
|
||||||
var gpuTemperature = jsonObject.computer.curves.gpuTemperature
|
var gpuTemperature = getPropertyWithDefault(jsonObject.computer.curves, 'gpuTemperature', 0)
|
||||||
|
|
||||||
var gpuUsedSerie = gpuChart.createSeries(ChartView.SeriesTypeLine, "GPU", valueAxisX3, valueAxisY3)
|
var gpuUsedSerie = gpuChart.createSeries(ChartView.SeriesTypeLine, "GPU", valueAxisX3, valueAxisY3)
|
||||||
var gpuUsedMemorySerie = gpuChart.createSeries(ChartView.SeriesTypeLine, "Memory", valueAxisX3, valueAxisY3)
|
var gpuUsedMemorySerie = gpuChart.createSeries(ChartView.SeriesTypeLine, "Memory", valueAxisX3, valueAxisY3)
|
||||||
|
@ -261,7 +265,6 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**************************
|
/**************************
|
||||||
*** UI ***
|
*** UI ***
|
||||||
**************************/
|
**************************/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue