<-- Previous || Up || Next -->

Math Built In Benchmark Sub
Math Reals Class

Private Sub MathBuiltInBenchmark()
    ' Perform a benchmark on the built-in Visual Basic functions.

    'See also:
    '  ComplexNumbersBenchmark Subroutine
    '  TrigonometryBenchmark Subroutine

    Dim lngMax As Long
    Dim lngTry As Long
    Dim varRtn As Variant


    lngMax = 102400
    Debug.Print "Count = " & lngMax


    Debug.Print "Abs: ";
    DebugTimerOn
    For lngTry = 1 To lngMax
        varRtn = Abs(Rnd * 6 - 3)
    Next lngTry
    Debug.Print DebugTimerOff

    Debug.Print "Exp: ";
    DebugTimerOn
    For lngTry = 1 To lngMax
        varRtn = Exp(Rnd * 6 - 3)
    Next lngTry
    Debug.Print DebugTimerOff

    Debug.Print "Log: ";
    DebugTimerOn
    For lngTry = 1 To lngMax
        varRtn = Log(Rnd * 6 + 1)
    Next lngTry
    Debug.Print DebugTimerOff

    Debug.Print "Sgn: ";
    DebugTimerOn
    For lngTry = 1 To lngMax
        varRtn = Sgn(Rnd * 6 - 3)
    Next lngTry
    Debug.Print DebugTimerOff

    Debug.Print "Sqr: ";
    DebugTimerOn
    For lngTry = 1 To lngMax
        varRtn = Sqr(Rnd * 6)
    Next lngTry
    Debug.Print DebugTimerOff


    Debug.Print "Sin: ";
    DebugTimerOn
    For lngTry = 1 To lngMax
        varRtn = Sin(Rnd * 6 - 3)
    Next lngTry
    Debug.Print DebugTimerOff

    Debug.Print "Cos: ";
    DebugTimerOn
    For lngTry = 1 To lngMax
        varRtn = Cos(Rnd * 6 - 3)
    Next lngTry
    Debug.Print DebugTimerOff

    Debug.Print "Tan: ";
    DebugTimerOn
    For lngTry = 1 To lngMax
        varRtn = Tan(Rnd * 6 - 3)
    Next lngTry
    Debug.Print DebugTimerOff

    Debug.Print "Atn: ";
    DebugTimerOn
    For lngTry = 1 To lngMax
        varRtn = Atn(Rnd * 6 - 3)
    Next lngTry
    Debug.Print DebugTimerOff

End Sub

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.