BBj Function Debugging


BBj 15.0 and higher includes low-level function debugging tools that can be enabled with a setting.  This feature imposes a very small, but non-zero cost; it should only be enabled for limited periods to gather information about function usage. .


To enable this feature, add the following setting to, then restart BBjServices:



When this feature is enabled, all function usage (counts and timings, measured in nanoseconds) are tracked system-wide (globally for BBjServices).  Values can be accessed with the following static variable and methods, all in com.basis.bbj.funcs.FunctionMgr:


Returns Static variable or method Returns
boolean FunctionMgr.DEBUG A boolean value indicating whether function usage is currently being tracked.
HashMap<String,Long> FunctionMgr.getDebugCounts() A map keyed by function name, containing all functions used during this BBjServices run (or since resetDebug() was called).  This returns counts of the number of times each function was called.
HashMap<String,Long> FunctionMgr.getDebugNanoTimes() A map keyed by function name, containing all functions used during this BBjServices run (or since resetDebug() was called).  This returns total execution time for each function, measured in nanoseconds.
void FunctionMgr.resetDebug() This method clears all logged function information from the maps described above.


rem ' BBj Function Debugging
rem ' Enable by adding this setting to
rem ' com.basis.bbj.funcs.debug=true
use com.basis.bbj.funcs.FunctionMgr
precision 9
print "com.basis.bbj.funcs.debug=",
print FunctionMgr.DEBUG
print "FunctionMgr.resetDebug()"
print "Use some BBj functions...."
print cvs(sys,3)," ",rev
print date(0:"%hz:%mz:%sz %p")
a = sqr(2)
b = sqr(100)
c = len("The quick brown fox jumps over the lazy dog.")
d = len("")
print "Report function timing statistics...."
counts! = FunctionMgr.getDebugCounts()
times! = FunctionMgr.getDebugNanoTimes()
print counts!
print times!
iter! = counts!.entrySet().iterator()
while iter!.hasNext()
  entry! = iter!.next()
  func$ = entry!.getKey()
  count = entry!.getValue()
  nano = times!.get(func$)
  print func$," was used",count," time(s) for a total of",
  print nano/1000000," ms (average",nano/count/1000000," ms)"

Sample Run

Use some BBj functions....
LEVEL 6 REV 15.00
09:12:53 am
Report function timing statistics....
{CVS=1, DATE=1, LEN=2, REV=1, SQR=2, SYS=1}
{CVS=10985, DATE=75027, LEN=3483, REV=32832, SQR=37734, SYS=2969}
CVS was used 1 time(s) for a total of .010985 ms (average .010985 ms)
DATE was used 1 time(s) for a total of .075027 ms (average .075027 ms)
LEN was used 2 time(s) for a total of .003483 ms (average .0017415 ms)
REV was used 1 time(s) for a total of .032832 ms (average .032832 ms)
SQR was used 2 time(s) for a total of .037734 ms (average .018867 ms)
SYS was used 1 time(s) for a total of .002969 ms (average .002969 ms)