Next: , Previous: , Up: CLOS   [Contents][Index]


2.23.7 Method Tracing and Profiling

Methods can be traced with trace, using function names of the form (method <name> <qualifiers> <specializers>). Example:

(defmethod foo ((x integer)) x)
(defmethod foo :before ((x integer)) x)

(trace (method foo (integer)))
(trace (method foo :before (integer)))
(untrace (method foo :before (integer)))

trace and untrace also allow a name specifier :methods gf-form for tracing all methods of a generic function:

(trace :methods 'foo)
(untrace :methods 'foo)

Methods can also be specified for the :wherein option to trace. Because this option is a name or a list of names, methods must be specified as a list. Thus, to trace all calls of foo from the method bar specialized on integer argument, use

  (trace foo :wherein ((method bar (integer))))

Before and after methods are supported as well:

  (trace foo :wherein ((method bar :before (integer))))

Method profiling is done analogously to trace:

(defmethod foo ((x integer)) x)
(defmethod foo :before ((x integer)) x)

(profile:profile (method foo (integer)))
(profile:profile (method foo :before (integer)))
(profile:unprofile (method foo :before (integer)))

(profile:profile :methods 'foo)
(profile:unprofile :methods 'foo)

(profile:profile-all :methods t)

Next: Misc, Previous: Sealing, Up: CLOS   [Contents][Index]