mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-03 00:38:41 +02:00
[ui] Display computation time for "running" or "finished" nodes
This commit is contained in:
parent
78e19a1a34
commit
5542516ba4
2 changed files with 106 additions and 0 deletions
|
@ -24,6 +24,96 @@ Panel {
|
|||
icon: MaterialLabel { text: MaterialIcons.tune }
|
||||
|
||||
headerBar: RowLayout {
|
||||
Label {
|
||||
text: {
|
||||
if (node !== null && node.isSubmittedOrRunning()) {
|
||||
// Some chunks might be submitted but they'll all run eventually
|
||||
if (node.elapsedTime > 0) { // At least a chunk is done running
|
||||
return "Running for: " + getTimeStr(node.elapsedTime)
|
||||
} else {
|
||||
return (node.chunks.count > 1) ? "First chunk running" : "Node running"
|
||||
}
|
||||
} else if (node !== null && node.isFinishedOrRunning()) {
|
||||
/* Either all chunks finished running or the last one is running
|
||||
* Placed inside an "else if" instead of "else" to avoid entering the functions
|
||||
* when there is no real use */
|
||||
return getTimeStr(node.elapsedTime)
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
padding: 2
|
||||
font.italic: true
|
||||
visible: {
|
||||
if (node !== null) {
|
||||
if ((node.isFinishedOrRunning() || node.isSubmittedOrRunning())) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
ToolTip.text: {
|
||||
if (node !== null && (node.isFinishedOrRunning() || (node.isSubmittedOrRunning() && node.elapsedTime > 0))) {
|
||||
var longestChunkTime = getLongestChunkTime(node.chunks)
|
||||
if (longestChunkTime > 0)
|
||||
return "Longest chunk: " + getTimeStr(longestChunkTime) + " (" + node.chunks.count + " chunks)"
|
||||
else
|
||||
return ""
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
ToolTip.visible: ToolTip.text ? runningTimeMa.containsMouse : false
|
||||
MouseArea {
|
||||
id: runningTimeMa
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
}
|
||||
|
||||
function getTimeStr(elapsed)
|
||||
{
|
||||
if (elapsed <= 0)
|
||||
return ""
|
||||
|
||||
var hours = 0
|
||||
var min = 0
|
||||
var finalTime = ""
|
||||
|
||||
if (elapsed > 3600) {
|
||||
hours = Math.floor(elapsed / 3600)
|
||||
elapsed = elapsed - (hours * 3600)
|
||||
finalTime += hours + "h"
|
||||
}
|
||||
if (elapsed > 60) {
|
||||
min = Math.floor(elapsed / 60)
|
||||
elapsed = elapsed - (min * 60)
|
||||
finalTime += min + "m"
|
||||
}
|
||||
if (hours == 0 && min == 0) {
|
||||
// Millisecond precision for execution times below 1 min
|
||||
finalTime += Number(elapsed.toLocaleString(Qt.locale('en-US'))) + "s"
|
||||
} else {
|
||||
finalTime += Math.round(elapsed) + "s"
|
||||
}
|
||||
|
||||
return finalTime
|
||||
}
|
||||
|
||||
function getLongestChunkTime(chunks)
|
||||
{
|
||||
if (chunks.count <= 1)
|
||||
return 0
|
||||
|
||||
var longestChunkTime = 0
|
||||
for (var i = 0; i < chunks.count; i++) {
|
||||
var elapsedTime = chunks.at(i).elapsedTime
|
||||
longestChunkTime = elapsedTime > longestChunkTime ? elapsedTime : longestChunkTime
|
||||
}
|
||||
return longestChunkTime
|
||||
}
|
||||
}
|
||||
|
||||
MaterialToolButton {
|
||||
text: MaterialIcons.more_vert
|
||||
font.pointSize: 11
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue