KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Retrieving Project and Database methods code sizes
PRODUCT: 4D | VERSION: 16 | PLATFORM: Mac & Win
Published On: July 27, 2017

Here is a utlity to check the code sizes in bytes for Project and Database methods:

// --------------------------------------------------------------------------------
// Name: GET_METHOD_SIZE
// Description: Method will extract the Project methods or Database methods to get
// the individual size in bytes as well as the total size of all methods.
// Input:
// $1 (LONGINT) - Choice of methods to get the size
// (0 - Database methods, 1 - Project methods
// $2 (POINTER) - Pointer to array of method names
// $3 (POINTER) - Pointer to array of method name's sizes in bytes
// Output:
// $0 (REAL) - Total method size in bytes
// --------------------------------------------------------------------------------
C_LONGINT($1;$pathChoice)
C_POINTER($2;$arrMethodName)
C_POINTER($3;$arrMethodNameFileSize)
C_REAL($0;$totalFileSize)
ARRAY TEXT($arrPaths;0) // text arrays
C_TEXT($code;$methodName)
C_BLOB($blob)
C_LONGINT($fSize;$i)

If (Count parameters=3)
   
    $pathChoice:=$1
    $arrMethodName:=$2
    $arrMethodNameFileSize:=$3
   
    $methodName:=current method name
   
    If ($pathChoice=0)
     METHOD GET PATHS(Path database method;$arrPaths) // code of several methods
    Else
     METHOD GET PATHS(Path project method;$arrPaths) // code of several methods
    End if
   
    $totalFileSize:=0
    $fSize:=0

    For ($i;1;Size of array($arrPaths))
   
     If ($arrPaths{$i}#$methodName)
      METHOD GET CODE($arrPaths{$i};$code)
      TEXT TO BLOB($code;$blob)
      $fSize:=blob size($blob)
      $totalFileSize:=$totalFileSize+$fSize
      APPEND TO ARRAY($arrMethodName->;$arrPaths{$i})
      APPEND TO ARRAY($arrMethodNameFileSize->;$fSize)
     End if
    End for
End if

$0:=$totalFileSize


Here is a example of finding the sizes of the Database methods:

ARRAY TEXT(arrName;0)
ARRAY LONGINT(arrNameSize;0)
C_REAL($totalSize)

$totalSize:=GET_METHOD_SIZE (0;->arrName;->arrNameSize)


Here is the result:





Here is an example of finding the sizes of the Project methods:

$totalSize:=GET_METHOD_SIZE (1;->arrName;->arrNameSize)


Here is the result: