geob
Enthusiast
Enthusiast

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 -