Files
harbour-core/harbour/tests/testprof.prg
Przemyslaw Czerpak 503c1ddf13 2007-09-02 17:27 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/hbgtmk.sh
  * harbour/tests/codebl.prg
  * harbour/tests/testprof.prg
  * harbour/tests/keywords.prg
  * harbour/tests/testpp.prg
  * harbour/make_rpm.sh
  * harbour/makefile.gc
  * harbour/bin/hb-mkslib.sh
  * harbour/include/hbexpra.c
  * harbour/include/hbmath.ch
  * harbour/include/hbrddntx.h
  * harbour/include/hbexprb.c
  * harbour/harbour.spec
  * harbour/contrib/dot/pp.prg
  * harbour/contrib/libct/ctwin.c
  * harbour/contrib/ole2/w32ole.c
  * harbour/contrib/hgf/win32/win32.c
  * harbour/contrib/mysql/mysql.ch
  * harbour/contrib/odbc/todbc.prg
  * harbour/contrib/odbc/sql.ch
  * harbour/contrib/hb_struc/hbstruc.ch
  * harbour/contrib/bmdbfcdx/bmdbfcdx1.c
  * harbour/contrib/msql/msql.ch
  * harbour/contrib/msql/readme.txt
  * harbour/source/pp/ppcore.c
  * harbour/source/rtl/gtdos/gtdos.c
  * harbour/source/rtl/gtxwc/gtxwc.h
  * harbour/source/rtl/hbgtcore.c
  * harbour/source/rtl/gtcrs/gtcrs.h
  * harbour/source/rtl/gtalleg/gtalleg.c
  * harbour/source/rtl/gtalleg/ssf.h
  * harbour/source/rtl/gtalleg/fixedth.sfc
  * harbour/source/rtl/gtchrmap.c
  * harbour/source/rtl/itemseri.c
  * harbour/source/rtl/gtstd/gtstd.c
  * harbour/source/rtl/gtsln/gtsln.h
  * harbour/source/rtl/gttrm/gttrm.c
  * harbour/source/rtl/gtpca/gtpca.c
  * harbour/source/rtl/hbhex.c
  * harbour/source/rtl/tget.prg
  * harbour/source/rtl/gtcgi/gtcgi.c
  * harbour/source/rtl/hbinet.c
  * harbour/source/vm/hvm.c
  * harbour/source/debug/dbgtobj.prg
  * harbour/source/debug/dbgwa.prg
  * harbour/source/common/expropt2.c
  * harbour/source/rdd/dbfcdx/dbfcdx1.c
  * harbour/source/rdd/dbffpt/dbffpt1.c
  * harbour/utils/hbpp/hbppcore.c
  * harbour/utils/hbpptest/pp_test.prg
  * harbour/utils/hbpptest/pretest.prg
  * harbour/make_tgz.sh
    * converted TABs to SPACEs
2007-09-02 15:28:05 +00:00

115 lines
2.6 KiB
Plaintext

/*
* $Id$
*/
/* Test code for the harbour profiler API and the profile reporting classes */
#include "inkey.ch"
Function Main()
Local oProfile := HBProfile():new()
Local oGet := GetNew()
Local n
// Turn on profiling.
__setProfiler( .T. )
// 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( HBProfileReportToString():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( HBProfileReportToString():new( oProfile:nameSort() ):generate( {|o| o:nCalls > 0 } ), 1,,,, .F. )
// Sorted by time
DrawScreen( "All methods/functions taking measurable time, sorted by time" )
memoedit( HBProfileReportToString():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( HBProfileReportToTBrowse():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 )