From a804426ddd8636c5b9d9cbc2e94abc25c3fcbb29 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Thu, 24 Jan 2002 10:06:58 +0000 Subject: [PATCH] 2002-01-24 10:03 UTC+0000 Dave Pearson * source/rtl/profiler.prg + Added class HBProfileOPCode. + Added class HBProfileLowLevel. It inherits from HBProfile and adds OPCODE usage entries. --- harbour/ChangeLog | 6 ++ harbour/source/rtl/profiler.prg | 101 +++++++++++++++++++++++++++----- 2 files changed, 92 insertions(+), 15 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 0c7bad37c5..3fed52adb2 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,12 @@ 2002-12-01 23:12 UTC+0100 Foo Bar */ * 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 * include/hbpcode.h diff --git a/harbour/source/rtl/profiler.prg b/harbour/source/rtl/profiler.prg index 2b2a5f68ca..d887bf60c1 100644 --- a/harbour/source/rtl/profiler.prg +++ b/harbour/source/rtl/profiler.prg @@ -6,7 +6,7 @@ * Harbour Project source code: * Profiler reporting classes * - * Copyright 2001 Dave Pearson + * Copyright 2001,2002 Dave Pearson * 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