Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


How to use timer to clock speed of subs?


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-26-2008, 08:26 PM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 200
Default How to use timer to clock speed of subs?

Hi,

I want a very simple timer to clock the speed in several subs in order to tune up the speed of the application.
Is this enough?

Sub Globals
N = 10
STOP = FALSE
End Sub

Sub App_Start
Form1.Show
Timer1.Interval = 1 'minimum milliseconds
Timer1.Enabled = True
End Sub

Sub Something
STOP = FALSE

Do the thing.....

STOP = FALSE
End Sub

Sub Timer1_Tick
N = N+1
If STOP = FALSE Then Timer1.Enabled = False
lblTime.Text = N
End Sub

thnx
Marc

Last edited by Stellaferox : 02-26-2008 at 08:29 PM.
Reply With Quote
  #2 (permalink)  
Old 02-26-2008, 10:33 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 157
Default

Marc, you might do better to get the current time (in ticks) at the start of the routine, and again at the end, then take the difference of the two.

Gary
__________________
PC: Windows XP Pro SP3 / Basic4PPC v6.5
PPC: HTC 8925 (AT&T Tilt) / Windows Mobile 6
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 07:14 AM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 200
Default

Is that not what this routine does?
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 07:57 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

This will not work as the timer tick events will not fire while other code is running (unless you add the DoEvents keyword).
Just checking the value of Now will also not be enough because it is updated each second on the device.
The solution is to use GetTickCount from this library: Useful Library
Calculate its value in the beginning and end of each sub.
Reply With Quote
  #5 (permalink)  
Old 02-28-2008, 08:07 AM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 200
Default

thanks Erel,
This works great!
This forum is a real goldmine....
Marc
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Timer component 2220 Questions & Help Needed 4 09-27-2008 08:41 PM
Simple Chess Clock erzee Share Your Creations 1 07-25-2008 02:46 AM
Passing arrays to Subs. jesb4ppc Questions & Help Needed 6 04-15-2008 06:03 PM
Redundant SUBs badkarma Basic4ppc Wishlist 0 04-10-2008 08:50 PM
Icon near the clock vitramir Questions & Help Needed 7 12-13-2007 04:14 PM


All times are GMT. The time now is 03:20 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0