Quick Search for:  in language:    
ever,been,Which,part,routine,taking,long,wond
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Visual Basic Stats

 Code: 3,014,970. lines
 Jobs: 119. postings

 How to support the site

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for Visual Basic.
Unroll2 - Update
By Cyber Chris on 7/2


MultilinePWD
By Cyber Chris on 7/2


Click here to see a screenshot of this code!Song/Poem Assistant
By Peter Rowan on 7/2

(Screen Shot)

Click here to see a screenshot of this code!GPA Cal
By KBM-00 on 7/2

(Screen Shot)

Click here to see a screenshot of this code!Connection Via the Telephone line.No internet or cable.Just the telephone line
By Nass ClickMan on 7/2

(Screen Shot)

DBTool
By Make Strömberg on 7/2


Click here to see a screenshot of this code!MSChart Simple Example
By Sebastian Pereira on 7/2

(Screen Shot)

CString v1.5
By Ultimatum on 7/2


Tablature Pro
By Michael McMullen on 7/2


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

DebugTimer

Print
Email
 

Submitted on: 12/8/1997
By: Matthew Heydman  
Level: Not Given
User Rating: By 105 Users
Compatibility:VB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0

Users have accessed this code 11516 times.
 
 
     Have you ever been asked: Which part of the routine is taking so long? or did you ever wonder what function was bogging your app down, or did you ever just want to time a particular statement or function? Welcome to DebugTimer. It's not a resource hog and uses no active-x controls... just the built-in Timer function in VB. This is a very easily implemented class module that allows you to time any line(s) of code or functions or whatever. You can even use multiple timers or nest them. I wrote this to determine the length of time it took to perform various stored procedures, and it worked great. If you have a similar need, I'm sure this will do the trick.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

'**************************************
' Name: DebugTimer
' Description:Have you ever been asked: 
'     Which part of the routine is taking so l
'     ong? or did you ever wonder what functio
'     n was bogging your app down, or did you 
'     ever just want to time a particular stat
'     ement or function? Welcome to DebugTimer
'     . It's not a resource hog and uses no ac
'     tive-x controls... just the built-in Tim
'     er function in VB. This is a very easily
'     implemented class module that allows you
'     to time any line(s) of code or functions
'     or whatever. You can even use multiple t
'     imers or nest them. I wrote this to dete
'     rmine the length of time it took to perf
'     orm various stored procedures, and it wo
'     rked great. If you
have a similar need, I'm sure this will Do the trick.
' By: Matthew Heydman
'
'This code is copyrighted and has' limited warranties.Please see http://w
'     ww.Planet-Source-Code.com/vb/scripts/Sho
'     wCode.asp?txtCodeId=754&lngWId;=1'for details.'**************************************

'Add a new Form to your project, and add
'     3 command buttons to the
'form (named Command1, Command2, and Com
'     mand3). Then just
'paste the following code into the form:
'     
Option Explicit
Dim i As Integer
Dim dbg As New clsDebugTimer
Private Sub Command1_Click()

Me.MousePointer = vbHourglass 'EXAMPLE 1 - VERY BASIC USAGE ' Start the timer dbg.Begin 'Do something that will take a little ti ' me For i = 0 To 25000: DoEvents: Next 'By default, calling the ShowElapsed met ' hod 'will display the elapsed time in the im ' mediate window dbg.ShowElapsed Me.MousePointer = vbDefault End Sub
Private Sub Command2_Click()
Me.MousePointer = vbHourglass 'EXAMPLE 2 - USING THE PARAMETERS 'Start the timer, this time passing a 'timer index and a description dbg.Begin 0, "Loop from 0 To 25000" 'Do something that takes time For i = 0 To 25000: DoEvents: Next 'Display the elapsed time for timer inde ' x 0 in a message box dbg.ShowElapsed outMsgBox, 0 Me.MousePointer = vbDefault End Sub
Private Sub Command3_Click()
Me.MousePointer = vbHourglass 'EXAMPLE 3 - USING MULTIPLE TIMERS 'Start the first timer- we'll use an ind ' ex of 1 'timer index and a description dbg.Begin 1, "Total Time" 'Start a second timer- (index 2) 'timer index and a description dbg.Begin 2, "Count from 0 To 25000" 'Do something that takes time For i = 0 To 25000: DoEvents: Next 'Display the elapsed time for the second ' timer dbg.ShowElapsed outImmediateWindow, 2 'perform another loop like the one we ju ' st did above dbg.Begin 2, "Count from 0 To 24999" 'Do something that takes time For i = 0 To 24999: DoEvents: Next 'Display the elapsed time for the second ' timer dbg.ShowElapsed outImmediateWindow, 2 'Now display the elapsed time for the fi ' rst timer dbg.ShowElapsed outImmediateWindow, 1 Me.MousePointer = vbDefault End Sub


Other 1 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
4/16/1999 7:08:00 AM:Matt Dawdy
This is INCREDIBLY useful.  Thank you 
for posting it.  I am going to make 
this into a dll and then be able to 
reference it from any project, and that 
way I can include in during 
development, and then dump it quickly 
for final production.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/2/1999 6:22:00 PM:Lloyd Cox
Will this work in VBA?  Specifically 
Word 97.  I have a few templates that 
get bogged down and just seem to sit 
there at times and have been looking 
for a way to find out where the problem 
is.  
I tried to paste the code into 
VBA, but got some errors?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/4/2001 3:24:40 PM:Vijay
This is kewl. Even I had done this but 
it wasnt that robust. Good work keep it 
up.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/13/2002 1:44:36 PM:Matthew Heydman
Hmmm, some of the code is not appearing 
above... it used to, but I dunno what 
happened. You can view the complete 
post by clicking the "copy and paste 
friendly" link above above the code.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Visual Basic Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.