WebCamSrv:

- Update gestione thread in chiusura
- update stats con csv export
This commit is contained in:
Samuele Locatelli
2023-05-15 09:53:39 +02:00
parent 8df04e2760
commit e07d7d8d37
2 changed files with 43 additions and 4 deletions
+14 -2
View File
@@ -47,6 +47,7 @@ Partial Class ProcMan
Me.chOther = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader)
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.chkStatAggr = New System.Windows.Forms.CheckBox()
Me.btnExportStats = New System.Windows.Forms.Button()
Me.StatusStrip1.SuspendLayout()
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
@@ -72,7 +73,7 @@ Partial Class ProcMan
'lblTestAlive
'
Me.lblTestAlive.AutoSize = True
Me.lblTestAlive.Location = New System.Drawing.Point(431, 18)
Me.lblTestAlive.Location = New System.Drawing.Point(274, 18)
Me.lblTestAlive.Name = "lblTestAlive"
Me.lblTestAlive.Size = New System.Drawing.Size(25, 13)
Me.lblTestAlive.TabIndex = 3
@@ -80,7 +81,7 @@ Partial Class ProcMan
'
'btnTestAlive
'
Me.btnTestAlive.Location = New System.Drawing.Point(329, 13)
Me.btnTestAlive.Location = New System.Drawing.Point(172, 13)
Me.btnTestAlive.Name = "btnTestAlive"
Me.btnTestAlive.Size = New System.Drawing.Size(75, 23)
Me.btnTestAlive.TabIndex = 2
@@ -253,11 +254,21 @@ Partial Class ProcMan
Me.chkStatAggr.Text = "Aggr Stats"
Me.chkStatAggr.UseVisualStyleBackColor = True
'
'btnExportStats
'
Me.btnExportStats.Location = New System.Drawing.Point(459, 13)
Me.btnExportStats.Name = "btnExportStats"
Me.btnExportStats.Size = New System.Drawing.Size(75, 23)
Me.btnExportStats.TabIndex = 18
Me.btnExportStats.Text = "Export Stats"
Me.btnExportStats.UseVisualStyleBackColor = True
'
'ProcMan
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(552, 445)
Me.Controls.Add(Me.btnExportStats)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.txtQueue)
Me.Controls.Add(Me.StatusStrip1)
@@ -303,4 +314,5 @@ Partial Class ProcMan
Friend WithEvents chTime As ColumnHeader
Friend WithEvents chOther As ColumnHeader
Friend WithEvents chkStatAggr As CheckBox
Friend WithEvents btnExportStats As Button
End Class
+29 -2
View File
@@ -651,7 +651,7 @@ Public Class ProcMan
Sub(o)
If Not isUpdatingThreads Then
isUpdatingThreads = True
ProcStats.RecordData($"{m_MaxCamInstances}", tExeCam, tOther)
ProcStats.RecordData(m_MaxCamInstances, tExeCam, tOther)
ProcStats.RecordList.Enqueue((tId, tExeCam, tOther))
'Begin the update
LISTThreadStatus.BeginUpdate()
@@ -660,7 +660,6 @@ Public Class ProcMan
' compilo in base al tipo di stat richiesta
If (chkStatAggr.Checked) Then
' statistiche di sintesi
Dim sorted = From pair In ProcStats.ExeCumSum
Order By pair.Key
For Each item In sorted
@@ -755,6 +754,34 @@ Public Class ProcMan
End Structure
''' <summary>
''' Esportazione statistiche attuali esecuzione
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
Private Sub btnExportStats_Click(sender As Object, e As EventArgs) Handles btnExportStats.Click
' statistiche di sintesi
Dim sorted = From pair In ProcStats.ExeCumSum
Order By pair.Key
' preparo il file export...
Dim fileName As String
Dim adesso As DateTime = DateTime.Now
fileName = Path.Combine("C:\Temp\", $"WDC_Stats_{adesso:yyyyMMdd-HHmmss}.csv")
Dim sb As StringBuilder = New StringBuilder
sb.AppendLine("Threads;Samples;ExeTime;OtherTime;FullTime")
For Each item In sorted
' preparo la linea CSV...
sb.AppendLine($"{item.Key};{item.Value.NumRec};{item.Value.ExeTime / item.Value.NumRec:N2};{item.Value.OthTime / item.Value.NumRec:N2};{(item.Value.ExeTime + item.Value.OthTime) / item.Key:N2}")
Next
' scrivo!
File.WriteAllText(fileName, sb.ToString())
End Sub
Private Sub ProcMan_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
' forzo chiusura threads!
stopAllThreads()
End Sub
#End Region
End Class