5.3 Documentation addenda




monitor function-or-method
monitor-functions function-list
The macro monitor arranges for monitoring data to be gathered on the specified functions or methods.

The function monitor-functions is similar to the macro monitor except that monitor-functions takes a list of function names as its argument.

The function-or-method argument to monitor specifies a function name, a method object, or the name of a method to be monitored. The value that is specified is returned by monitor. A method name has the following form:

(method generic-function-name {qualifiers}* ({specializer-name}*))

If you do not specify the function-or-method argument, monitor returns a list of all the functions and methods currently being monitored.

The function-list argument to monitor-functions specifies a list of function names; this list is returned by monitor-functions. If the value of this argument is nil, monitor-functions returns a list of all the functions currently being monitored.

By default, monitoring occurs in all processes except the idle process. The monitoring information for a function's behavior in all of the processes is combined, not distinguished by process.

You can remove functions and methods from the set of constructs being monitored by calling the macro unmonitor or the function unmonitor-functions.

These constructs are extensions to Common Lisp.


;;; The following example shows how to monitor a method. For
;;; examples of monitoring functions, see the section "Using the
;;; Performance Monitor." This example assumes that the CLOS module
;;; has been loaded. 
;; Invoke the production mode of the Compiler. 
> (proclaim '(optimize (speed 3) (safety 1) (compilation-speed 0)))

;; Define a generic function PLUS. 
> (defgeneric plus (x y)) 
#<Standard-Generic-Function PLUS (0)> 

;; Define a POLYNOMIAL class that PLUS can operate on.
> (defclass polynomial () 
	;; A polynomial has just a vector of coefficients. 
	((coefficients :initarg :coefficients 
	:accessor poly-coeff 
	:initform #(0)))) 
#<Standard-Class POLYNOMIAL> 

;; Define a PLUS method for polynomials. 
>  (defmethod plus ((x polynomial) (y polynomial)) 
	(let*  ((x-coef (poly-coeff x)) 
	(y-coef (poly-coeff y)) 
	(maxlen (max (length x-coef) (length y-coef))) 
	(minlen (min (length x-coef) (length y-coef))) 
	(result-coefficients (make-array maxlen))) 
	(unless (= maxlen (length x-coef)) 
	;; Make sure x is longer. 
	(rotatef x-coef y-coef)) 
	(dotimes (i maxlen) 
	(setf (aref result-coefficients i) 
	(if (>= i minlen) 
	(aref x-coef i) 
	(+ (aref y-coef i) (aref x-coef i))))) 
	(make-instance 'polynomial :coefficients result-

;; Compile the PLUS method for polynomials. 
> (compile '(method plus (polynomial polynomial))) 

;; Make the method eligible for monitoring. 
> (monitor (method plus (polynomial polynomial))) 

;; Enable the monitoring procedure. 
> (start-monitoring) 
> (plus (make-instance 'polynomial :coefficients #(3 4 5 2 0 8 7))
	 (make-instance 'polynomial :coefficients #(3 4 5 2 0 7))) #<Polynomial #XDD6383>
;; Disable monitoring. 
> (stop-monitoring) 

;; Show the results of monitoring. 
> (print-monitor '(method plus (polynomial polynomial)))
 Monitor information for (METHOD PLUS (POLYNOMIAL POLYNOMIAL))
Number of calls 	: 1 
Inclusive Time (secs) 	: 0.010 
Exclusive Time (secs) 	: 0.010 
Inclusive Consing (words) 	: 290 
Exclusive Consing (words) 	: 290 

;; Make the method ineligible for monitoring. 
> (unmonitor (method plus (polynomial polynomial))) 

Liquid Common Lisp 5.0 Release and Installation Notes - 9 JUN 1997

Generated with Harlequin WebMaker