2001-08-23 23:18 GMT Dave Pearson <davep@davep.org>
* source/rtl/profiler.prg
* Minor tidy-up of a couple of comments.
* tests/testprof.org
* Updated to test the various reporting classes.
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2001-08-23 23:18 GMT Dave Pearson <davep@davep.org>
|
||||
* source/rtl/profiler.prg
|
||||
* Minor tidy-up of a couple of comments.
|
||||
* tests/testprof.org
|
||||
* Updated to test the various reporting classes.
|
||||
|
||||
2001-08-23 22:51 GMT Dave Pearson <davep@davep.org>
|
||||
* doc/readme.txt
|
||||
* Cut down to a bare minimum. Most of the information in there was
|
||||
|
||||
@@ -76,10 +76,10 @@
|
||||
*
|
||||
* As much as possible, the profiler class and the profile report classes
|
||||
* attempt to turn off the profiler to ensure that we don't get some sort of
|
||||
* Heisenberg effect. IOW, we don't want the profiler showing up in the
|
||||
* profiler.
|
||||
* Heisenberg effect. In other words, we don't want the profiler showing up
|
||||
* in the profiler.
|
||||
*
|
||||
* Many of the "Protected:" scope specifiers in the source have beenc
|
||||
* Many of the "Protected:" scope specifiers in the source have been
|
||||
* commented out where there's a problem with scope in harbour's class
|
||||
* system. Note that those comments will be removed when the bug is fixed.
|
||||
*
|
||||
|
||||
@@ -1,16 +1,114 @@
|
||||
// Testing the Harbour profiler
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
function Main()
|
||||
/* Test code for the harbour profiler API and the profile reporting classes */
|
||||
|
||||
local lPrevProf := __SetProfiler( .t. ) // First of all, we activate the profiler
|
||||
local oGet := GetNew()
|
||||
local oBrw := TBrowseNew()
|
||||
local n
|
||||
#include "inkey.ch"
|
||||
|
||||
for n = 1 to 20000
|
||||
oGet:row = 10
|
||||
next
|
||||
Function Main()
|
||||
Local oProfile := HB_Profile():new()
|
||||
Local oGet := GetNew()
|
||||
Local n
|
||||
|
||||
hb_Profiler( "profile.txt" ) // look for a generated profiler.txt file on your disk
|
||||
// Turn on profiling.
|
||||
__setProfiler( .T. )
|
||||
|
||||
return nil
|
||||
// Make sure we've got something to see timewise.
|
||||
DrawScreen( "Doing nothing for a couple of seconds" )
|
||||
DoNothingForTwoSeconds()
|
||||
|
||||
// Make sure we've got something to see callwise.
|
||||
For n := 1 To 500
|
||||
CallMe500Times()
|
||||
Next
|
||||
|
||||
// Generate some object oriented (oriented? <g>) entries.
|
||||
For n := 1 To 500
|
||||
oGet:row := 0
|
||||
Next
|
||||
|
||||
// Take a profile snapshot.
|
||||
oProfile:gather()
|
||||
|
||||
// Report on calls greater than 0
|
||||
DrawScreen( "All methods/functions called one or more times" )
|
||||
memoedit( HB_ProfileReportToString():new( oProfile:callSort() ):generate( {|o| o:nCalls > 0 } ), 1,,,, .F. )
|
||||
|
||||
// Sorted by name
|
||||
DrawScreen( "All methods/functions called one or more times, sorted by name" )
|
||||
memoedit( HB_ProfileReportToString():new( oProfile:nameSort() ):generate( {|o| o:nCalls > 0 } ), 1,,,, .F. )
|
||||
|
||||
// Sorted by time
|
||||
DrawScreen( "All methods/functions taking measurable time, sorted by time" )
|
||||
memoedit( HB_ProfileReportToString():new( oProfile:timeSort() ):generate( {|o| o:nTicks > 0 } ), 1,,,, .F. )
|
||||
|
||||
// TBrowse all calls greater than 0
|
||||
DrawScreen( "TBrowse all methods/functions called one or more times" )
|
||||
Browser( HB_ProfileReportToTBrowse():new( oProfile:callSort() ):generate( {|o| o:nCalls > 0 }, 1 ) )
|
||||
|
||||
// Some closing stats
|
||||
DrawScreen( "Totals" )
|
||||
@ 2, 0 Say " Total Calls: " + str( oProfile:totalCalls() )
|
||||
@ 3, 0 Say " Total Ticks: " + str( oProfile:totalTicks() )
|
||||
@ 4, 0 Say "Total Seconds: " + str( oProfile:totalSeconds() )
|
||||
|
||||
Return( NIL )
|
||||
|
||||
Static Function DrawScreen( cTitle )
|
||||
|
||||
scroll()
|
||||
|
||||
@ 0, 0 Say padr( cTitle, maxcol() + 1 ) Color "n/w"
|
||||
|
||||
Return( NIL )
|
||||
|
||||
Function DoNothingForTwoSeconds()
|
||||
|
||||
inkey( 2 )
|
||||
|
||||
Return( NIL )
|
||||
|
||||
Function CallMe500Times()
|
||||
Return( NIL )
|
||||
|
||||
Static Function Browser( oBrowse )
|
||||
Local lBrowsing := .T.
|
||||
Local nKey
|
||||
|
||||
Do While lBrowsing
|
||||
|
||||
oBrowse:forceStable()
|
||||
|
||||
nKey := inkey( 0 )
|
||||
|
||||
Do Case
|
||||
|
||||
Case nKey == K_ESC
|
||||
lBrowsing := .F.
|
||||
|
||||
Case nKey == K_DOWN
|
||||
oBrowse:down()
|
||||
|
||||
Case nKey == K_UP
|
||||
oBrowse:up()
|
||||
|
||||
Case nKey == K_LEFT
|
||||
oBrowse:left()
|
||||
|
||||
Case nKey == K_RIGHT
|
||||
oBrowse:right()
|
||||
|
||||
Case nKey == K_PGDN
|
||||
oBrowse:pageDown()
|
||||
|
||||
Case nKey == K_PGUP
|
||||
oBrowse:pageUp()
|
||||
|
||||
// And so on.... (not really necessary for this test)
|
||||
|
||||
EndCase
|
||||
|
||||
EndDo
|
||||
|
||||
Return( NIL )
|
||||
|
||||
Reference in New Issue
Block a user