Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Oct 23, 2017 7:24 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: AppProfiler - Calculate Code Speed
PostPosted: Sat Sep 29, 2012 12:19 pm 
Offline
User avatar

Joined: Sat May 27, 2006 3:27 pm
Posts: 480
Hello

Here is a simple example of a poor mans code profiler. This will help you to be able to determine the codes execution speed!

Hope this helps

1. Make 2 Methods in your App name them StartProfiler and StopProfiler
2. make 2 Date property's in your App name them StartSeconds and EndSeconds

App Methods
Sub App.StartProfiler()
StartSeconds = New Date
End Sub


Sub App.StopProfiler()
EndSeconds = New Date
Msgbox("Total(" + Format( Val(Str( EndSeconds.Second - StartSeconds.Second )) , "00" ) +") Seconds" )
End Sub


3. Call it like this

Call App.StartProfiler
'Code goes here
Call App.StopProfiler


Example Code:
===================================
Sub Buttons.Action()
ListBox1.DeleteAllRows
Call App.StartProfiler
For i As Integer = 1 to 5000
App.DoEvents(1)
Window1.ListBox1.AddRow Str(i)
Next
Call App.StopProfiler
End Sub


Top
 Profile  
Reply with quote  
 Post subject: Re: AppProfiler - Calculate Code Speed
PostPosted: Sat Sep 29, 2012 1:27 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
**app.doevents is for console based apps generally

Awesome :-)

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: AppProfiler - Calculate Code Speed
PostPosted: Sat Sep 29, 2012 9:14 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
You could also use Microseconds instead of a Date to measure periods shorter than 1 second.

_________________
Boredom Software


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group