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

Sort Characters Benchmark Sub
Character Arrays Class

Private Sub SortCharactersBenchmark()
    ' Test the SortCharactersBenchmark function.

    Dim intTry As Integer
    Dim intTries As Integer
    intTries = 16
    
    Dim strOrig As String
    Dim strTemp As String
    Dim strRtn As String

    Dim intCopies As Integer
    intCopies = 1
    Do
        strOrig = RepeatString(intCopies, EveryCharacter)

        Debug.Print "Length = " & Len(strOrig)
        Debug.Print "# Tries = " & intTries

        Debug.Print "Binary  :          ";
        DebugTimerOn
        For intTry = 1 To intTries
            strRtn = SortCharactersBinary(strOrig)
        Next intTry
        Debug.Print DebugTimerOff

        Debug.Print "Original:          ";
        DebugTimerOn
        For intTry = 1 To intTries
            strRtn = SortCharacters(strOrig, vbBinaryCompare)
        Next intTry
        Debug.Print DebugTimerOff

        Debug.Print "Original Reversed: ";
        strTemp = ReverseString(strOrig)
        DebugTimerOn
        For intTry = 1 To intTries
            strRtn = SortCharacters(strTemp, vbBinaryCompare)
        Next intTry
        Debug.Print DebugTimerOff

        Debug.Print "Sorted:            ";
        strTemp = SortCharacters(strOrig, vbBinaryCompare)
        DebugTimerOn
        For intTry = 1 To intTries
            strRtn = SortCharacters(strTemp, vbBinaryCompare)
        Next intTry
        Debug.Print DebugTimerOff

        Debug.Print "Sorted Reversed:   ";
        strTemp = ReverseString(strRtn)
        DebugTimerOn
        For intTry = 1 To intTries
            strRtn = SortCharacters(strTemp, vbBinaryCompare)
        Next intTry
        Debug.Print DebugTimerOff

        Debug.Print "Shuffle String:    ";
        DebugTimerOn
        For intTry = 1 To intTries
            strRtn = ShuffleString(strOrig)
        Next intTry
        Debug.Print DebugTimerOff

        intCopies = intCopies * 2
        If intTries > 1 Then intTries = intTries \ 2
    Loop While intCopies <= 4096 / 256
End Sub

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