Tech Tip: Utility method for capturing GET CACHE STATISTICS
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac & Win
Published On: February 8, 2012
Utility method for capturing GET CACHE STATISTICS
The GET CACHE STATISTICS (GCS) command returns information about 4D's cache. Here is a utility method that can be used to get and save information generated from this command.
Note, this method saves the information into a table within the database. If the table does not already exist, it is created.
// Method: UTIL_Save_GCS C_TEXT($1;$note_t;$usedCache_t) C_LONGINT($pos_l) ARRAY TEXT($names_at;0) ARRAY REAL($values_ar;0) ARRAY REAL($count_ar;0) If (Count parameters>0) $note_t:=$1 Else $note_t:="" End if //make sure table exists Begin SQL CREATE TABLE IF NOT EXISTS CacheStatistics (primKey UUID AUTO_GENERATE, dateTime VARCHAR, usedCache VARCHAR, note VARCHAR); End SQL //extract the wanted information GET CACHE STATISTICS(1;$names_at;$values_ar;$count_ar) $pos_l:=Find in array($names_at;"usedCacheSize") $usedCache_t:=String($values_ar{$pos_l}) //save the wanted information into a new record in the table Begin SQL INSERT INTO CacheStatistics (dateTime, usedCache, note) VALUES (CAST (CURRENT_TIMESTAMP() AS VARCHAR), :$usedCache_t, :$note_t); End SQL |
Here are a few examples of how this utility method can be used:
UTIL_Save_GCS UTIL_Save_GCS ("pre report generation") UTIL_Save_GCS ("post report generation") |
Also, this method saves one piece of data that is generated from the GCS command. Additional information from the GCS command can be added to this method if it suits the developers purposes.