Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » Utilities » Downloads
 
Add your own
alternative version
Go to top

Comparative Speed Testing

, 28 May 2008
A simple-to-use class for performing comparative, non-benchmarked speed tests when optimising code for execution speed.
#Region "[=== OPTIONS ===]"

Option Strict On
Option Explicit On
Option Compare Binary

#End Region

''' <summary>
''' clsSpeedTestAB_Properties - Speed test Property versus direct field access.
''' </summary>
''' <overview>
''' </overview>
''' <remarks>
''' </remarks>
''' <notes>
''' </notes>
Public Class clsSpeedTestAB_Properties
  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 f_SomeInteger As Int32 = 123456

  Public Property SomeInteger() As Int32
    Get
      Return Me.f_SomeInteger
    End Get
    Set(ByVal value As Int32)
      Me.f_SomeInteger = value
    End Set
  End Property

#End Region

#Region "[=== SPEED TEST OVERRIDE METHODS ===]"

  ''' <summary>
  ''' Overriden speed test A setup.
  ''' </summary>
  ''' <remarks></remarks>
  Protected Overrides Sub SetUpTestA()
    Me.f_DescribeA = "Access a public field directly."
  End Sub

  ''' <summary>
  ''' Overriden speed test A setup.
  ''' </summary>
  ''' <remarks></remarks>
  Protected Overrides Sub SetUpTestB()
    Me.f_DescribeB = "Access a field via a property."
  End Sub

  ''' <summary>
  ''' Overridden Speed Test A.
  ''' </summary>
  ''' <remarks></remarks>
  Protected Overrides Sub SpeedTestA()
    Dim xInt As Int32
    xInt = Me.f_SomeInteger
  End Sub

  ''' <summary>
  ''' Overridden Speed Test B.
  ''' </summary>
  ''' <remarks></remarks>
  Protected Overrides Sub SpeedTestB()
    Dim xInt As Int32
    xInt = Me.SomeInteger
  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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Warrick Procter
ZED
New Zealand New Zealand
A DEC PDP/11 BasicPlus2 developer from the 80s.

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 29 May 2008
Article Copyright 2008 by Warrick Procter
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid