2002-01-24 10:03 UTC+0000 Dave Pearson <davep@davep.org>

* source/rtl/profiler.prg
     + Added class HBProfileOPCode.
     + Added class HBProfileLowLevel. It inherits from HBProfile and adds
       OPCODE usage entries.
This commit is contained in:
Dave Pearson
2002-01-24 10:06:58 +00:00
parent 3292075b00
commit a804426ddd
2 changed files with 92 additions and 15 deletions

View File

@@ -8,6 +8,12 @@
2002-12-01 23:12 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
* tests/testpers.prg
Tests if the string contains a " and uses single quotes
instead, or use [] if it contains both.
Future enhancement should cover if contains all 3....
* contrib/rdd_ads/adsfunc.c
2002-01-24 17:53 UTC+0000 Dave Pearson <davep@davep.org>
* include/hbpcode.h

View File

@@ -6,7 +6,7 @@
* Harbour Project source code:
* Profiler reporting classes
*
* Copyright 2001 Dave Pearson <davep@davep.org>
* Copyright 2001,2002 Dave Pearson <davep@davep.org>
* http://www.davep.org/
*
* This program is free software; you can redistribute it and/or modify
@@ -291,6 +291,23 @@ End Class
Method describe Class HBProfileMethod
Return( "Method" )
////////////////////////////////////////////////////////////////////////////
// Class: HBProfileOPCode
Create Class HBProfileOPCode Inherit HBProfileEntity
Exported:
Method describe
End Class
/////
Method describe Class HBProfileOPCode
Return( "OPCode" )
////////////////////////////////////////////////////////////////////////////
// Class: HBProfile
@@ -313,6 +330,8 @@ Create Class HBProfile
Protected:
Method gatherFunctions
Method gatherMethods
Method reset
Method ignoreSymbol
@@ -345,22 +364,12 @@ Return( ( left( cSymbol, len( cProfPrefix ) ) == cProfPrefix ) .Or. ( cSymbol ==
/////
Method gather Class HBProfile
Method gatherFunctions Class HBProfile
Local lProfile := __setProfiler( .F. )
Local nSymCount := __DynSCount()
Local cName
Local aPInfo
Local cClass
Local nMembers
Local aMembers
Local nMember
Local n
// Reset the profile.
::reset()
// First, collect function call data.
// For each known symbol.
// TODO: Question: Will the symbol count have changed because
// we've created variables?
@@ -379,9 +388,19 @@ Local n
Next
// Now collect classes.
__setProfiler( lProfile )
n := 1
Return( self )
/////
Method gatherMethods Class HBProfile
Local lProfile := __setProfiler( .F. )
Local n := 1
Local cClass
Local nMembers
Local aMembers
Local nMember
// For each class in the environment...
Do While !empty( cClass := __className( n ) )
@@ -397,7 +416,7 @@ Local n
// If we've got a member name...
If !empty( aMembers[ nMember ] )
// Add it to the profile.
aadd( ::aProfile, HbProfileMethod():new( cClass + ":" + aMembers[ nMember ], __GetMsgPrf( n, aMembers[ nMember ] ) ) )
aadd( ::aProfile, HBProfileMethod():new( cClass + ":" + aMembers[ nMember ], __GetMsgPrf( n, aMembers[ nMember ] ) ) )
EndIf
Next
@@ -414,6 +433,24 @@ Return( self )
/////
Method gather Class HBProfile
Local lProfile := __setProfiler( .F. )
// Reset the profile.
::reset()
// Gather function calls
::gatherFunctions()
// Gather method calls
::gatherMethods()
__setProfiler( lProfile )
Return( self )
/////
Method forEach( b ) Class HBProfile
Local lProfile := __setProfiler( .F. )
@@ -503,6 +540,40 @@ Local nSeconds := 0
Return( nSeconds )
////////////////////////////////////////////////////////////////////////////
// Class: HBProfileLowLevel
Create Class HBProfileLowLevel Inherit HBProfile
Exported:
Method gather
Protected:
Method gatherOPCodes
End Class
/////
Method gather Class HBProfileLowLevel
Return( ::super:gather():gatherOPCodes() )
/////
Method gatherOPCodes Class HBProfileLowLevel
Local nMax := __opcount()
Local nOP
// Loop over all the harbour OP codes. Note that they start at 0.
For nOP := 0 To ( nMax - 1 )
// Add it to the profile.
aadd( ::aProfile, HBProfileOPCode():new( "OPCODE( " + alltrim( str( nOP ) ) + " )", __OpGetPrf( nOP ) ) )
Next
Return( self )
////////////////////////////////////////////////////////////////////////////
// Class: HBProfileReport