|
#Region "[=== OPTIONS ===]"
Option Strict On
Option Explicit On
Option Compare Binary
#End Region
''' <summary>
''' clsSpeedTestAB_Delegates - Speed test Select-Case and Delegate Functions.
''' </summary>
''' <overview>
''' </overview>
''' <remarks>
''' </remarks>
''' <notes>
''' </notes>
Public Class clsSpeedTestAB_Delegates
Inherits ZED.Utility.Development.clsBaseSpeedTestAB
#Region "[=== CONSTRUCTORS DESTRUCTORS INITIALISATION ===]"
''' <summary>
''' Construct a new speed test with prescribed repetitions.
''' </summary>
''' <param name="aRepetitions"></param>
''' <remarks></remarks>
Public Sub New(ByVal aRepetitions As Int32)
MyBase.New(aRepetitions)
End Sub
#End Region
#Region "[=== SPEED TEST COMPONENTS ===]"
Protected Function PR_GetIndex_Format1bppIndexed _
(ByVal aMap As Int32, ByVal aCol As Int32) As Int32
Return CByte((aMap >> (7 - (aCol Mod 8))) And 1)
End Function
Protected Function PR_GetIndex_Format4bppIndexed _
(ByVal aMap As Int32, ByVal aCol As Int32) As Int32
Return CByte((aMap >> ((aCol Mod 2) * 4)) And 15)
End Function
Protected Function PR_GetIndex_Format8bppIndexed _
(ByVal aMap As Int32, ByVal aCol As Int32) As Int32
' Return the 8-bit index.
Return aMap
End Function
Protected Delegate Function DelegateFunction _
(ByVal aMap As Int32, ByVal aCol As Int32) As Int32
Protected f_Col As Int32 = 1234
Protected f_Map As Int32 = 187
Protected f_Function As Int32 = 4
Protected f_Delegate As DelegateFunction
#End Region
#Region "[=== SPEED TEST OVERRIDE METHODS ===]"
''' <summary>
''' Overriden speed test A setup.
''' </summary>
''' <remarks></remarks>
Protected Overrides Sub SetUpTestB()
Me.f_DescribeB = "Call functions directly from Select Case."
End Sub
''' <summary>
''' Overriden speed test A setup.
''' </summary>
''' <remarks></remarks>
Protected Overrides Sub SetUpTestA()
Me.f_DescribeA = "Call functions indirectly by delegate."
Me.f_Delegate = AddressOf Me.PR_GetIndex_Format4bppIndexed
End Sub
''' <summary>
''' Overridden Speed Test B.
''' </summary>
''' <remarks></remarks>
Protected Overrides Sub SpeedTestB()
Dim xInt As Int32
Select Case Me.f_Function
Case 1
xInt = Me.PR_GetIndex_Format1bppIndexed(Me.f_Map, Me.f_Col)
Case 4
xInt = Me.PR_GetIndex_Format4bppIndexed(Me.f_Map, Me.f_Col)
Case 8
xInt = Me.PR_GetIndex_Format8bppIndexed(Me.f_Map, Me.f_Col)
End Select
End Sub
''' <summary>
''' Overridden Speed Test A.
''' </summary>
''' <remarks></remarks>
Protected Overrides Sub SpeedTestA()
Dim xInt As Int32
xInt = Me.f_Delegate(Me.f_Map, Me.f_Col)
End Sub
#End Region
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.