' vbc /optimize /optionexplicit /optionstrict pftest5.vb
Imports System
Module pftest5
Sub Test()
Const MAXDIM As Integer = 30000
Dim sum As Double = 0.0
Dim rdm As New Random()
Dim dm(MAXDIM-1) As Double
Dim i As Integer, j As Integer
Dim temp As Double
For i = 0 To MAXDIM-1
dm(i) = rdm.NextDouble()
Next
Dim tstart As Integer = System.Environment.TickCount
For i = 0 To MAXDIM-1
j = MAXDIM - i - 1
dm(i) = dm(i) * dm(j) + 1
Next
For i = 0 To MAXDIM-1
j = MAXDIM - 1
Do While j > i
If dm(i) > dm(j) Then
temp = dm(i)
dm(i) = dm(j)
dm(j) = temp
End If
j = j - 1
Loop
Next
For i = 0 To MAXDIM-1
j = MAXDIM - i - 1
dm(i) = dm(i) * dm(j) - 1
Next
For i = 0 To MAXDIM-1
sum = sum + dm(i)
Next
Dim tend As Integer = System.Environment.TickCount
Console.WriteLine("SUM = {0} : elpased = {1}", sum, tend - tstart)
End Sub
Sub Main()
Dim i As Integer
Console.WriteLine("VB.NET")
For i = 1 To 10
Test()
Next
End Sub
End Module
JyB2YmMgL29wdGltaXplIC9vcHRpb25leHBsaWNpdCAvb3B0aW9uc3RyaWN0IHBmdGVzdDUudmIKCkltcG9ydHMgU3lzdGVtCgpNb2R1bGUgcGZ0ZXN0NQogIFN1YiBUZXN0KCkKICAgIENvbnN0IE1BWERJTSBBcyBJbnRlZ2VyID0gMzAwMDAKICAgIERpbSBzdW0gQXMgRG91YmxlID0gMC4wCiAgICBEaW0gcmRtIEFzIE5ldyBSYW5kb20oKQoKICAgIERpbSBkbShNQVhESU0tMSkgQXMgRG91YmxlCgogICAgRGltIGkgQXMgSW50ZWdlciwgaiBBcyBJbnRlZ2VyCiAgICBEaW0gdGVtcCBBcyBEb3VibGUKCiAgICBGb3IgaSA9IDAgVG8gTUFYRElNLTEKICAgICAgZG0oaSkgPSByZG0uTmV4dERvdWJsZSgpCiAgICBOZXh0CgogICAgRGltIHRzdGFydCBBcyBJbnRlZ2VyID0gU3lzdGVtLkVudmlyb25tZW50LlRpY2tDb3VudAoKICAgIEZvciBpID0gMCBUbyBNQVhESU0tMQogICAgICBqID0gTUFYRElNIC0gaSAtIDEKICAgICAgZG0oaSkgPSBkbShpKSAqIGRtKGopICsgMQogICAgTmV4dAoKICAgIEZvciBpID0gMCBUbyBNQVhESU0tMQogICAgICAgIGogPSBNQVhESU0gLSAxCiAgICAgICAgRG8gV2hpbGUgaiA+IGkKICAgICAgICAgICAgSWYgZG0oaSkgPiBkbShqKSBUaGVuCiAgICAgICAgICAgICAgICB0ZW1wID0gZG0oaSkKICAgICAgICAgICAgICAgIGRtKGkpID0gZG0oaikKICAgICAgICAgICAgICAgIGRtKGopID0gdGVtcAogICAgICAgICAgICBFbmQgSWYKICAgICAgICAgICAgaiA9IGogLSAxCiAgICAgICAgTG9vcAogICAgTmV4dAoKICAgIEZvciBpID0gMCBUbyBNQVhESU0tMQogICAgICAgIGogPSBNQVhESU0gLSBpIC0gMQogICAgICAgIGRtKGkpID0gZG0oaSkgKiBkbShqKSAtIDEKICAgIE5leHQKCiAgICBGb3IgaSA9IDAgVG8gTUFYRElNLTEKICAgICAgICBzdW0gPSBzdW0gKyBkbShpKQogICAgTmV4dAoKICAgIERpbSB0ZW5kIEFzIEludGVnZXIgPSBTeXN0ZW0uRW52aXJvbm1lbnQuVGlja0NvdW50CgogICAgQ29uc29sZS5Xcml0ZUxpbmUoIlNVTSA9IHswfSA6IGVscGFzZWQgPSB7MX0iLCBzdW0sIHRlbmQgLSB0c3RhcnQpCiAgRW5kIFN1YgoKICBTdWIgTWFpbigpCiAgICBEaW0gaSBBcyBJbnRlZ2VyCiAgICBDb25zb2xlLldyaXRlTGluZSgiVkIuTkVUIikKICAgIEZvciBpID0gMSBUbyAxMAogICAgICBUZXN0KCkKICAgIE5leHQKICBFbmQgU3ViCkVuZCBNb2R1bGUK