add edmi benchmark
This commit is contained in:
114
GUIs.Test.EDMIBenchmark/Form1.vb
Normal file
114
GUIs.Test.EDMIBenchmark/Form1.vb
Normal file
@@ -0,0 +1,114 @@
|
||||
Imports System.ServiceModel
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.EDMI.API
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DevExpress.XtraEditors.Controls
|
||||
Imports System.IO
|
||||
|
||||
Public Class Form1
|
||||
Private _Channel As EDMIServiceReference.IEDMIServiceChannel
|
||||
|
||||
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
Dim oLogConfig As New LogConfig(LogConfig.PathType.Temp)
|
||||
Dim oChannelFactory As New ChannelFactory(Of EDMIServiceReference.IEDMIServiceChannel)(
|
||||
Channel.GetBinding(TcpClientCredentialType.Windows),
|
||||
"net.tcp://172.24.12.39:9000/DigitalData/Services/Main")
|
||||
_Channel = oChannelFactory.CreateChannel()
|
||||
_Channel.Open()
|
||||
End Sub
|
||||
|
||||
Private Sub ButtonSelectFiles_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles ButtonSelectFiles.ItemClick
|
||||
Dim oDialog As New OpenFileDialog() With {
|
||||
.Multiselect = True,
|
||||
.CheckFileExists = True
|
||||
}
|
||||
Dim oResult = oDialog.ShowDialog()
|
||||
|
||||
If oResult = DialogResult.OK Then
|
||||
For Each oFileName In oDialog.FileNames
|
||||
listboxFiles.Items.Add(oFileName)
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Async Sub ButtonImportFiles_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles ButtonImportFiles.ItemClick
|
||||
Dim oFiles As New List(Of String)
|
||||
Dim oSWTotal As New Stopwatch()
|
||||
oSWTotal.Start()
|
||||
|
||||
For Each oItem As String In listboxFiles.Items
|
||||
Dim oSW As New Stopwatch()
|
||||
oSW.Start()
|
||||
Dim oFileName As String = oItem
|
||||
Dim oFileInfo As New FileInfo(oFileName)
|
||||
|
||||
listboxLog.Items.Add($"Importing {oFileInfo.Name}...")
|
||||
|
||||
Dim oContents As Byte() = New Byte(oFileInfo.Length) {}
|
||||
|
||||
Using oStream As New FileStream(oFileName, FileMode.Open)
|
||||
Await oStream.ReadAsync(oContents, 0, oFileInfo.Length)
|
||||
End Using
|
||||
|
||||
Dim oResult As EDMIServiceReference.DocumentResult2 = Await _Channel.ImportFileAsync(oFileInfo, oContents, False, 0)
|
||||
If oResult.OK Then
|
||||
listboxLog.Items.Add($"File {oFileInfo.Name} imported!")
|
||||
Else
|
||||
listboxLog.Items.Add($"Import Error: {oResult.ErrorMessage}")
|
||||
End If
|
||||
oSW.Stop()
|
||||
listboxLog.Items.Add($"Import Time: {FormatTime(oSW.ElapsedMilliseconds)}")
|
||||
listboxLog.Items.Add($"File Size: {FormatBytes(oFileInfo.Length)}")
|
||||
listboxLog.Items.Add("")
|
||||
Next
|
||||
|
||||
oSWTotal.Stop()
|
||||
listboxLog.Items.Add($"Total Time: {FormatTime(oSWTotal.ElapsedMilliseconds)}")
|
||||
listboxLog.MakeItemVisible(listboxLog.Items.Count - 1)
|
||||
End Sub
|
||||
|
||||
Private Sub buttonClearLog_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles buttonClearLog.ItemClick
|
||||
listboxLog.Items.Clear()
|
||||
End Sub
|
||||
|
||||
Private Sub buttonClearFiles_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles buttonClearFiles.ItemClick
|
||||
listboxFiles.Items.Clear()
|
||||
End Sub
|
||||
|
||||
Public Function FormatTime(Milliseconds As Integer) As String
|
||||
If Milliseconds < 1000 Then
|
||||
Return Milliseconds & " ms"
|
||||
Else
|
||||
Return (Milliseconds / 1000) & " s"
|
||||
End If
|
||||
End Function
|
||||
|
||||
Dim DoubleBytes As Double
|
||||
Public Function FormatBytes(ByVal BytesCaller As ULong) As String
|
||||
|
||||
Try
|
||||
Select Case BytesCaller
|
||||
Case Is >= 1099511627776
|
||||
DoubleBytes = CDbl(BytesCaller / 1099511627776) 'TB
|
||||
Return FormatNumber(DoubleBytes, 2) & " TB"
|
||||
Case 1073741824 To 1099511627775
|
||||
DoubleBytes = CDbl(BytesCaller / 1073741824) 'GB
|
||||
Return FormatNumber(DoubleBytes, 2) & " GB"
|
||||
Case 1048576 To 1073741823
|
||||
DoubleBytes = CDbl(BytesCaller / 1048576) 'MB
|
||||
Return FormatNumber(DoubleBytes, 2) & " MB"
|
||||
Case 1024 To 1048575
|
||||
DoubleBytes = CDbl(BytesCaller / 1024) 'KB
|
||||
Return FormatNumber(DoubleBytes, 2) & " KB"
|
||||
Case 0 To 1023
|
||||
DoubleBytes = BytesCaller ' bytes
|
||||
Return FormatNumber(DoubleBytes, 2) & " bytes"
|
||||
Case Else
|
||||
Return ""
|
||||
End Select
|
||||
Catch
|
||||
Return ""
|
||||
End Try
|
||||
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user