Swarm is a Java/Objective-C framework for agent based modelling (ABM). logzone is a set of classes to facilitate monitoring of Zones in Swarm. It is available from the swarm.org archive or from the author’s website
logzone is free software, distributed under the GNU GPL.
The package comes as a gzipped tar archive file.
APPLIBS=/path/liblogzone.a |
There is no limit on the number of LoggingZones. I used logzone to debug itself, for example.
The examples assume the header file is included, and both logzone and logger are temporary ids.
#import "/path/LoggingZone.h" ... id logzone, logger; |
Default The default behaviour is to give you sorted cumulative info in a graphics window.
logzone = [LoggingZone create: globalZone]; observerSwarm = [AquariumObserverSwarm create: logzone]; |
File/stdout You can also send alloc info (non-cumulative) to a file/stdout.
logzone = [LoggingZone createBegin: globalZone]; [logzone setAsciiFilename: 0]; // to stdout logzone = [logzone createEnd]; observerSwarm = [AquariumObserverSwarm create: logzone]; |
The ASCIIMemLoggers’ output consists of data records containing fields shown in the following table.
# | Type | Description | Comments |
1 | number | step no. | -1 if not in activity |
2 | string | alloc/free | ’+’ for alloc, ’-’ for free |
3 | string | class name | |
4 | hex string | mem location | |
5 | number | object size | |
6 | number | no. of objects | always 1 if not cumulative |
Delimiter It is also possible to set a refined logger, e.g. log cumulative info separated by commata to a file named testlog.
logzone = [LoggingZone createBegin: globalZone]; logger = [AsciiMemLogger createBegin: globalZone]; [logger setCumulative]; [logger setFilename: "testlog"]; [logger setRecordDelim: "\n" dataDelim: ","]; logger = [logger createEnd]; [logzone setMemLogConsumer: logger]; logzone = [logzone createEnd]; |
ScrathchZone/GlobalZone One can even log scratchZone/globalZone by replacing it with a LoggingZone.
logzone = [LoggingZone createBegin: globalZone]; [logzone setAsciiFilename: 0]; // to stdout // WARNING: using a more complicated logger may result in infinite loops. scratchZone = [logzone createEnd]; |
R output The RMemLogger can be used to log single (de)allocation events or per step.
logzone = [LoggingZone createBegin: globalZone]; logger = [RMemLogger createBegin: globalZone]; [logger setCumulative]; [logger setFilename: "rlog"]; logger = [logger createEnd]; [logzone setMemLogConsumer: logger]; logzone = [logzone createEnd]; |
frame <- read.table("rlog",header=TRUE) |
Here is an example of an awk script to cumulate alloc info from the (default non-cumulative) ASCII output.
BEGIN { arr[0]=0 } { if ( $3 in arr ) { if ( $2 ~ /\+/ ) arr[$3] = arr[$3]+1 else arr[$3] = arr[$3]-1 } else { if ( $2 ~ /\+/ ) arr[$3] = 1 } } END { for ( i in arr ) print i,arr[i] } |
Please send patches to: ralf@ark.in-berlin.de.