Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) 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, 07:26 PM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 269
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 07:29 PM.
Reply With Quote
  #2 (permalink)  
Old 02-26-2008, 09:33 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 162
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, 06:14 AM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 269
Default

Is that not what this routine does?
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 06:57 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
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: http://www.basic4ppc.com/forum/additional-libraries/384-useful-library.html
Calculate its value in the beginning and end of each sub.
Reply With Quote
  #5 (permalink)  
Old 02-28-2008, 07:07 AM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 269
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 Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing arrays to Subs. jesb4ppc Questions (Windows Mobile) 12 04-24-2009 09:05 AM
Timer component 2220 Questions (Windows Mobile) 4 09-27-2008 07:41 PM
Simple Chess Clock erzee Share Your Creations 1 07-25-2008 01:46 AM
Icon near the clock vitramir Questions (Windows Mobile) 7 12-13-2007 03:14 PM


All times are GMT. The time now is 02:02 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0