ToolCollection/ToolCollection/ModuleStopwatch.vb
Digital Data - Marlon Schreiber 9147029ea9 MoveRename
2019-09-04 16:37:05 +02:00

37 lines
1.5 KiB
VB.net

Module ModuleStopwatch
Public Class SW
Public label As String
Public stopwatch As Stopwatch
Public Sub New(label As String)
Me.label = label
stopwatch = New Stopwatch()
stopwatch.Start()
End Sub
Public Function Done() As Long
If My.Settings.vLogErrorsonly = True Then Return 0
stopwatch.Stop()
Dim ts As TimeSpan = stopwatch.Elapsed
Dim timespan_ = String.Format("{0:00}:{1:00}.{2:00}", ts.Minutes, ts.Seconds, ts.Milliseconds / 10)
If ts.Minutes > 0 Then
timespan_ = String.Format("{0:00}:{1:00}.{2:00}", ts.Minutes, ts.Seconds, ts.Milliseconds / 10)
ElseIf ts.Seconds > 0 And (ts.Minutes > 0) = False Then
timespan_ = String.Format("{0:00}.{1:00} seconds", ts.Seconds, ts.Milliseconds / 10)
ElseIf (ts.Seconds > 0) = False And ts.Milliseconds > 0 Then
timespan_ = String.Format("{0:00}.{1:00} seconds", ts.Seconds, ts.Milliseconds / 10)
End If
If timespan_ <> "00:00.00" Then
Dim message = String.Format("{0} || {1}", timespan_, label)
Console.WriteLine(message)
ClassLoggerDI.Add(message, False)
If My.Settings.vLogErrorsonly = False Then ClassLoggerDI.Add(message, False)
End If
Return stopwatch.ElapsedMilliseconds
End Function
End Class
End Module