Real Software Forums
http://forums.realsoftware.com/

AppProfiler - Calculate Code Speed
http://forums.realsoftware.com/viewtopic.php?f=21&t=45474
Page 1 of 1

Author:  sinner [ Sat Sep 29, 2012 12:19 pm ]
Post subject:  AppProfiler - Calculate Code Speed

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

Author:  simulanics [ Sat Sep 29, 2012 1:27 pm ]
Post subject:  Re: AppProfiler - Calculate Code Speed

**app.doevents is for console based apps generally

Awesome :-)

Author:  charonn0 [ Sat Sep 29, 2012 9:14 pm ]
Post subject:  Re: AppProfiler - Calculate Code Speed

You could also use Microseconds instead of a Date to measure periods shorter than 1 second.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/