' Journal zum Benchmarken der Ladezeiten, in NX/Mgr wie auch NXnative ' basiert auf einem aehnlichen Journal aus den bbsnotes (TestBlockPerformance) ' 2008-11-28 ugnx@zwatz.net ' Option Strict Off Imports System Imports System.IO Imports System.Windows.Forms Imports NXOpen Imports NXOpen.UF Imports NXOpen.Utilities Module TestLoadPerformance Dim Ses As Session = Session.GetSession() Dim UFSes As UFSession = UFSession.GetUFSession() Dim UISes As UI = UI.GetUI() Dim TempPath As String = Environment.GetEnvironmentVariable("TMP") Dim TestHostName As String = Environment.GetEnvironmentVariable("COMPUTERNAME") Dim UGRelease As String = Nothing Dim UGFullRelease As String = Nothing Dim UGIISiteDirPath As String = Nothing Dim UGIIFMSSetting As String = Nothing ' Testpart definieren Dim testpart_itemID As String = "2181.00.000.0" Dim testpart_revision As String = "0" Sub Main Ses.LogFile.WriteLine("Executing ... " & Ses.ExecutingJournal) UFSes.UF.TranslateVariable("UGII_VERSION", UGRelease) UFSes.UF.TranslateVariable("UGII_FULL_VERSION", UGFullRelease) UFSes.UF.TranslateVariable("UGII_SITE_DIR", UGIISiteDirPath) UFSes.UF.TranslateVariable("UGII_UGMGR_FMS", UGIIFMSSetting) Dim LogFile As String Dim StartTime, EndTime, ElapsedTime As TimeSpan Dim Failure As String = "Succeeded" LogFile = Path.Combine(TempPath, "LoadPerformanceLog_" & TestHostName & ".txt") If File.Exists(LogFile) = True Then File.Delete(LogFile) Ses.ListingWindow.SelectDevice(ListingWindow.DeviceType.FileAndWindow,LogFile) Ses.ListingWindow.Open() Ses.ListingWindow.WriteLine("") Ses.ListingWindow.WriteLine("HostName " & TestHostName) Ses.ListingWindow.WriteLine("") Ses.ListingWindow.WriteLine("NX " & UGFullRelease) Ses.ListingWindow.WriteLine("") Ses.ListingWindow.WriteLine("NX Customization: UGII_SITE_DIR set to " & UGIISiteDirPath) Ses.ListingWindow.WriteLine("") Ses.ListingWindow.WriteLine("NX Setting UGII_UGMGR_FMS is set to " & UGIIFMSSetting) Ses.ListingWindow.WriteLine("Set to DISABLED means FMS is not used ...") Ses.ListingWindow.WriteLine("") Ses.ListingWindow.WriteLine("Loading " & testpart_itemID & "/" & testpart_revision) StartTime = DateTime.Now.TimeOfDay Dim testpart_loadstring As String = TempPath & "\Testparts\" & testpart_itemID & "_" & testpart_revision & ".prt" Dim testpart_loadstring_NXMgr As String = "@DB/" & testpart_itemID & "/" & testpart_revision ' Check for NXMGR ... Dim is_active As Boolean UFses.UF.IsUgmanagerActive(is_active) Dim basePart1 As BasePart Dim partLoadStatus1 As PartLoadStatus If (is_active) Then basePart1 = Ses.Parts.OpenBaseDisplay(testpart_loadstring_NXMgr, partLoadStatus1) Else basePart1 = Ses.Parts.OpenBaseDisplay(testpart_loadstring, partLoadStatus1) End If Dim workPart As Part = Ses.Parts.Work Dim displayPart As Part = Ses.Parts.Display partLoadStatus1.Dispose() EndTime = DateTime.Now.TimeOfDay ElapsedTime = EndTime.Subtract(StartTime) Ses.ListingWindow.WriteLine("Loading Testpart ... " & Failure) Ses.ListingWindow.WriteLine(" Start Time ... " & FormatTime(StartTime)) Ses.ListingWindow.WriteLine(" End Time ... " & FormatTime(EndTime)) Ses.ListingWindow.WriteLine(" Elapsed ... " & FormatTime(ElapsedTime)) Ses.ListingWindow.WriteLine("") Ses.ListingWindow.WriteLine("Elapsed Time for Part Loading ... " & FormatTime(ElapsedTime)) Ses.ListingWindow.WriteLine("") Ses.ListingWindow.WriteLine(GetSystemInfo()) Ses.ListingWindow.WriteLine("") Ses.ListingWindow.Close() Ses.ListingWindow.SelectDevice(ListingWindow.DeviceType.Window,"") Ses.ListingWindow.Open() Ses.ListingWindow.WriteLine("") Ses.ListingWindow.WriteLine("Information listing saved to:") Ses.ListingWindow.WriteLine(vbTab & LogFile) End Sub Function FormatTime(TimeValue As TimeSpan) As String return TimeValue.Hours.ToString("00") & ":" & _ TimeValue.Minutes.ToString("00") & ":" & _ TimeValue.Seconds.ToString("00") & "." & _ TimeValue.Milliseconds.ToString("000") End Function Function GetSystemInfo() As String Dim SystemInfo As String = Nothing Dim InfoFile As String = TempPath & "\GetSystemInfo.txt" Dim VBScript As String = TempPath & "\GetSystemInfo.vbs" Dim VBFile As StreamWriter Dim TxtFile As StreamReader Dim VBProc As Diagnostics.Process VBFile = New StreamWriter(VBScript) VBFile.WriteLine( "On Error Resume Next" ) VBFile.WriteLine( "" ) VBFile.WriteLine( "Set fso = CreateObject(" & Chr(34) & "Scripting.FileSystemObject" & Chr(34) & ")" ) VBFile.WriteLine( "" ) VBFile.WriteLine( "Set LogFile = fso.CreateTextFile(" & Chr(34) & InfoFile & Chr(34) & ", True)" ) VBFile.WriteLine( "" ) VBFile.WriteLine( "LogFile.WriteLine()" ) VBFile.WriteLine( "LogFile.WriteLine(" & Chr(34) & "Computer System" & Chr(34) & ")" ) VBFile.WriteLine( "" ) VBFile.WriteLine( "For Each objComp in GetObject(" & Chr(34) & "winmgmts:" & Chr(34) & ").InstancesOf(" & Chr(34) & "Win32_ComputerSystem" & Chr(34) & ")" ) VBFile.WriteLine( "" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "Caption = " & Chr(34) & " & objComp.Caption)" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "Manufacturer = " & Chr(34) & " & objComp.Manufacturer)" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "Model = " & Chr(34) & " & objComp.Model)" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "SystemType = " & Chr(34) & " & objComp.SystemType)" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "NumberOfProcessors = " & Chr(34) & " & objComp.NumberOfProcessors)" ) VBFile.WriteLine( "Next" ) VBFile.WriteLine( "" ) VBFile.WriteLine( "LogFile.WriteLine()" ) VBFile.WriteLine( "LogFile.WriteLine(" & Chr(34) & "Operating System" & Chr(34) & ")" ) VBFile.WriteLine( "" ) VBFile.WriteLine( "For Each objOS in GetObject(" & Chr(34) & "winmgmts:" & Chr(34) & ").InstancesOf(" & Chr(34) & "Win32_OperatingSystem" & Chr(34) & ")" ) VBFile.WriteLine( "" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "Caption = " & Chr(34) & " & objOS.Caption)" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "Version = " & Chr(34) & " & objOS.Version)" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "CSDVersion = " & Chr(34) & " & objOS.CSDVersion)" ) VBFile.WriteLine( " LogFile.WriteLine()" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "MaxProcessMemorySize = " & Chr(34) & " & FormatNumber(CDbl(objOS.MaxProcessMemorySize) / 1024,0) & " & Chr(34) & " MByte" & Chr(34) & ")" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "TotalVirtualMemorySize = " & Chr(34) & " & FormatNumber(CDbl(objOS.TotalVirtualMemorySize) /1024,0) & " & Chr(34) & " MByte" & Chr(34) & ")" ) VBFile.WriteLine( "Next" ) VBFile.WriteLine( "" ) VBFile.WriteLine( "LogFile.WriteLine(" & Chr(34) & "Physical Memory" & Chr(34) & ")" ) VBFile.WriteLine( "" ) VBFile.WriteLine( "Set TotalCapacity = 0" ) VBFile.WriteLine( "" ) VBFile.WriteLine( "For Each objMEM in GetObject(" & Chr(34) & "winmgmts:" & Chr(34) & ").InstancesOf(" & Chr(34) & "Win32_PhysicalMemory" & Chr(34) & ")" ) VBFile.WriteLine( " TotalCapacity = TotalCapacity + CDbl(objMEM.Capacity)" ) VBFile.WriteLine( "Next" ) VBFile.WriteLine( "" ) VBFile.WriteLine( "LogFile.WriteLine(vbTab & " & Chr(34) & "Total Capacity = " & Chr(34) & " & FormatNumber(TotalCapacity / 1024 / 1024,0) & " & Chr(34) & " MByte" & Chr(34) & ")" ) VBFile.WriteLine( "" ) VBFile.WriteLine( "LogFile.WriteLine()" ) VBFile.WriteLine( "LogFile.WriteLine(" & Chr(34) & "Processor" & Chr(34) & ")" ) VBFile.WriteLine( "" ) VBFile.WriteLine( "For Each objCPU in GetObject(" & Chr(34) & "winmgmts:" & Chr(34) & ").InstancesOf(" & Chr(34) & "Win32_Processor" & Chr(34) & ")" ) VBFile.WriteLine( "" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "Name = " & Chr(34) & " & Trim(objCPU.Name))" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "Manufacturer = " & Chr(34) & " & objCPU.Manufacturer)" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "MaxClockSpeed = " & Chr(34) & " & FormatNumber(objCPU.MaxClockSpeed,0) & " & Chr(34) & " GHz" & Chr(34) & ")" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "CurrentClockSpeed = " & Chr(34) & " & FormatNumber(objCPU.CurrentClockSpeed,0) & " & Chr(34) & " GHz" & Chr(34) & ")" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "ExtClock = " & Chr(34) & " & FormatNumber(objCPU.ExtClock,0) & " & Chr(34) & " MHz" & Chr(34) & ")" ) VBFile.WriteLine( "" ) VBFile.WriteLine( " LogFile.WriteLine()" ) VBFile.WriteLine( "Next" ) VBFile.WriteLine( "" ) VBFile.WriteLine( "LogFile.WriteLine()" ) VBFile.WriteLine( "LogFile.WriteLine(" & Chr(34) & "Video Controller" & Chr(34) & ")" ) VBFile.WriteLine( "" ) VBFile.WriteLine( "For Each objDC in GetObject(" & Chr(34) & "winmgmts:" & Chr(34) & ").InstancesOf(" & Chr(34) & "Win32_VideoController" & Chr(34) & ")" ) VBFile.WriteLine( "" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "Caption = " & Chr(34) & " & objDC.Caption)" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "VideoProcessor = " & Chr(34) & " & objDC.VideoProcessor)" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "AdapterRAM = " & Chr(34) & " & FormatNumber(objDC.AdapterRAM / 1024 / 1024,0) & " & Chr(34) & " MByte" & Chr(34) & ")" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "DriverVersion = " & Chr(34) & " & objDC.DriverVersion)" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "DriverDate = " & Chr(34) & " & StringToDate(objDC.DriverDate))" ) VBFile.WriteLine( " LogFile.WriteLine(vbTab & " & Chr(34) & "VideoModeDescription = " & Chr(34) & " & objDC.CurrentHorizontalResolution & _" ) VBFile.WriteLine( " " & Chr(34) & " x " & Chr(34) & " & objDC.CurrentVerticalResolution & _" ) VBFile.WriteLine( " " & Chr(34) & " x " & Chr(34) & " & objDC.CurrentBitsPerPixel & " & Chr(34) & "bpp" & Chr(34) & ")" ) VBFile.WriteLine( "Next" ) VBFile.WriteLine( "" ) VBFile.WriteLine( "LogFile.Close" ) VBFile.WriteLine( "" ) VBFile.WriteLine( "WScript.Quit" ) VBFile.WriteLine( "" ) VBFile.WriteLine( "Function StringToDate(sDate)" ) VBFile.WriteLine( " sYear = Left(sDate, 4)" ) VBFile.WriteLine( " sMonth = Mid(sDate, 5, 2)" ) VBFile.WriteLine( " sDay = Mid(sDate, 7, 2)" ) VBFile.WriteLine( "" ) VBFile.WriteLine( " sHour = Mid(sDate, 9, 2)" ) VBFile.WriteLine( " sMinute = Mid(sDate, 11, 2)" ) VBFile.WriteLine( " sSecond = Mid(sDate, 13, 2)" ) VBFile.WriteLine( "" ) VBFile.WriteLine( " StringToDate = CDate(sMonth & " & Chr(34) & "/" & Chr(34) & " & sDay & " & Chr(34) & "/" & Chr(34) & " & sYear & " & Chr(34) & " " & Chr(34) & " & sHour & " & Chr(34) & ":" & Chr(34) & " & sMinute & " & Chr(34) & ":" & Chr(34) & " & sSecond)" ) VBFile.WriteLine( "End Function" ) VBFile.Flush() VBFile.Close() VBProc = Diagnostics.Process.Start(VBScript) VBProc.WaitForExit() TxtFile = New StreamReader(InfoFile) SystemInfo = TxtFile.ReadToEnd() TxtFile.Close() Return SystemInfo End Function End Module