little Benchmark

BlitzMax Forums/BlitzMax Programming/little Benchmark

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Is there any reason for the X variable to be an integer? It works faster when it is declared as Double, as the Y variable, this way, the test makes much more sense to me.

I've converted the code to Visual Basic .net and it took 9 seconds with the debug on, and 93 milliseconds running with the program built and no debuger present. So I supose you tested C# from the visual studio IDE over a debug build, try it over a release build directly from windows, and I supose you'll get a much better performance.

Sample code (the program has a form with a button and a textbox)
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Anzahl As Integer, Iterationen As Integer, EndTime As Long
        Dim StartTime As Long
        Dim i As Long
        Dim DauerMsec As DateTime
        Dim x As Double, y As Double
        Anzahl = 10000
        Iterationen = ((Anzahl - 1) * Anzahl / 2)

        EndTime = Now.Ticks

        For i = 0 To Iterationen
            y = Math.Sin(i)
            x = Math.Cos(y)
            x = x * y
        Next
        StartTime = Now.Ticks

        DauerMsec = New DateTime(StartTime - EndTime)

        SPrint("Anzahl: " & Anzahl)
        SPrint("Iterationen: " & Iterationen)
        SPrint("Time: " & DauerMsec.ToString & " " & DauerMsec.Millisecond)

    End Sub
    Sub SPrint(ByVal Str As String)
        Me.TextBox1.AppendText(Str & Chr(13) & Chr(10))
    End Sub
End Class


(I thought .net would be slower but oh surprise!)