home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 4_2005-2006.ISO / data / Zips / Stretching1888045132005.psc / cTiming.cls < prev   
Text File  |  2005-05-03  |  2KB  |  67 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "cTiming"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. '================================================
  15. ' Class:         cTiming.cls
  16. ' Author:        -
  17. ' Dependencies:  None
  18. ' Last revision: -
  19. '================================================
  20.  
  21. Option Explicit
  22.  
  23. '-- API:
  24.  
  25. Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long
  26. Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long
  27.  
  28. '//
  29.  
  30. '-- Private variables:
  31. Private m_Frequency As Currency
  32. Private m_Start     As Currency
  33. Private m_Now       As Currency
  34. Private m_Available As Boolean
  35.  
  36.  
  37.  
  38. '========================================================================================
  39. ' Class
  40. '========================================================================================
  41.  
  42. Private Sub Class_Initialize()
  43.  
  44.     m_Available = (QueryPerformanceFrequency(m_Frequency) <> 0)
  45.     
  46.     If (m_Available) Then
  47.         Debug.Print "Ticks/sec: "; m_Frequency * 10000
  48.       Else
  49.         Debug.Print "Performance Counter not available"
  50.     End If
  51. End Sub
  52.  
  53. '========================================================================================
  54. ' Methods
  55. '========================================================================================
  56.  
  57. Friend Sub Reset()
  58.     QueryPerformanceCounter m_Start
  59. End Sub
  60.  
  61. Friend Function Elapsed() As Double
  62.     Call QueryPerformanceCounter(m_Now)
  63.     If (m_Available) Then
  64.         Elapsed = 1000 * (m_Now - m_Start) / m_Frequency
  65.     End If
  66. End Function
  67.