All Posts

I took it one step further, and made it multi-threaded. I compiled this in VB 2010, and it worked great. I then set a batch file up to run from VMware Tools at start up. It will peg a 2 Proc... See more...
I took it one step further, and made it multi-threaded. I compiled this in VB 2010, and it worked great. I then set a batch file up to run from VMware Tools at start up. It will peg a 2 Proc VM. - Begine Code - #Region " Imports " Imports System.Threading #End Region #Region " Module Module1 " Module Module1 #Region " Sub Main " Sub Main() Try Dim tmpWorker1 As New Thread(AddressOf Worker_Thread_1) Dim tmpWorker2 As New Thread(AddressOf Worker_Thread_2) tmpWorker1.Name = "Worker Thread # 1" tmpWorker2.Name = "Worker Thread # 2" tmpWorker1.Priority = ThreadPriority.Normal tmpWorker2.Priority = ThreadPriority.Normal 'tmpWorker1.IsBackground = True 'tmpWorker2.IsBackground = True tmpWorker1.Start() tmpWorker2.Start() Catch ex As Exception Console.WriteLine(ex.Message) End Try End Sub #End Region #Region " Private Sub Worker_Thread_1 " Private Sub Worker_Thread_1() Try Dim goal As Long Dim x As Long Dim y As Long Dim i As Long goal = 2181818 Do While True Dim BeginTime As DateTime = Now For i = 0 To goal x = 0.000001 y = Math.Sin(x) y = y + 0.00001 Next y = y + 0.01 Dim Span As TimeSpan = DateTime.Now.Subtract(BeginTime) Console.WriteLine("CPUWorkOut(Worker1) processed three million sines in " & Span.Milliseconds & " milliseconds!") Loop Catch ex As Exception Console.WriteLine(ex.Message) End Try End Sub #End Region #Region " Private Sub Worker_Thread_2 " Private Sub Worker_Thread_2() Try Dim goal As Long Dim x As Long Dim y As Long Dim i As Long goal = 2181818 Do While True Dim BeginTime As DateTime = Now For i = 0 To goal x = 0.000001 y = Math.Sin(x) y = y + 0.00001 Next y = y + 0.01 Dim Span As TimeSpan = DateTime.Now.Subtract(BeginTime) Console.WriteLine("CPUWorkOut(Worker2) processed three million sines in " & Span.Milliseconds & " milliseconds!") Loop Catch ex As Exception Console.WriteLine(ex.Message) End Try End Sub #End Region End Module #End Region - End Code -
Here you go: I just made it a .net using VS 2010 express, set as a console applcation, compiled as .net 2.0, and made a few tweeks to make it run in .net. It would be pretty nerdy fun to rac... See more...
Here you go: I just made it a .net using VS 2010 express, set as a console applcation, compiled as .net 2.0, and made a few tweeks to make it run in .net. It would be pretty nerdy fun to race the .vbs vs this .exe.. Now if you ask me to make this a multi-threaded app, Ill have to go ask my friends.. Zip file is also here: www.four2.org/cpubusy Source code - >8---- Module Module1 Sub Main() Console.Out.WriteLine(vbCrLf) Console.Out.WriteLine("ported to VB .net by Jonathan Reininger VCP 3.5/4.0 5/19/2010") Console.Out.WriteLine(vbCrLf) Dim goal Dim before Dim x Dim y Dim i y = 0 goal = 2181818 Do While True before = Timer For i = 0 To goal x = 0.000001 'y = sin(x) 'from orig .vbs version y = System.Math.Sin(x) y = y + 0.00001 Next y = y + 0.01 Console.Out.WriteLine("I did three million sines in " & Timer - before & " seconds!") Loop End Sub
Any of you coders know how to convert the following VBsript code to code that would function in Visual Basic console app? --Script Begin --- Dim goal Dim before Dim x Dim y Dim i ... See more...
Any of you coders know how to convert the following VBsript code to code that would function in Visual Basic console app? --Script Begin --- Dim goal Dim before Dim x Dim y Dim i goal = 2181818 Do While True before = Timer For i = 0 to goal x = 0.000001 y = sin(x) y = y + 0.00001 Next y = y + 0.01 WScript.Echo "I did three million sines in " & Int(Timer - before + 0.5) & " seconds!" Loop -Script End - Thanks in advance. Geob
You might want to post your inquiry on the PowerCLI forums: http://communities.vmware.com/community/vmtn/vsphere/automationtools/powercli This is the just the sample code repo, not sure how ma... See more...
You might want to post your inquiry on the PowerCLI forums: http://communities.vmware.com/community/vmtn/vsphere/automationtools/powercli This is the just the sample code repo, not sure how many monitor this forum. There are some great gurus on the PowerCLI forum that should be able help answer your question ========================================================================= William Lam VMware vExpert 2009 VMware ESX/ESXi scripts and resources at: Twitter: @lamw VMware Code Central - Scripts/Sample code for Developers and Administrators VMware Developer Community If you find this information useful, please award points for "correct" or "helpful".
Hi, I'm new in PowerCLI. I'm using next script to obtain Virtual Machine Inventory: $outputFileVM = 'D:\PowerShell_scripts\Inventory.csv' $VMReport = @() get-vm | sort name | %{ ... See more...
Hi, I'm new in PowerCLI. I'm using next script to obtain Virtual Machine Inventory: $outputFileVM = 'D:\PowerShell_scripts\Inventory.csv' $VMReport = @() get-vm | sort name | %{ $VM = Get-View $_.ID $row = "" | Select-Object VM_Name, VM_Host, VM_Host_Model, VM_Memory, VM_vCpu, VM_CpuLimit, VM_CpuShares $row.VM_Name = $VM.Config.Name $row.VM_Host = Get-VMHost -VM $_ $row.VM_Host_Model = Get-VMHost -VM $_ | Get-View | % {$_.Hardware.SystemInfo.Model} $row.VM_Memory = $VM.Config.Hardware.memoryMB $row.VM_vCpu = $VM.Config.Hardware.numCPU $row.VM_CpuLimit = $VM.Config.CpuAllocation.Limit $row.VM_CpuShares = $VM.Config.CpuAllocation.Shares.Shares $VMReport += $row } $VMReport | Export-Csv $outputFileVM -NoTypeInformation This script runs very slow. I read something about how to increase speed using get-view -viewType. But I don't know how to use it to refactory in this script. Anyone can help me? Thanks. Eduard.