LispWorks User Guide and Reference Manual > 32 The HCL Package

NextPrevUpTopContentsIndex

do-profiling

Function
Summary

A convenience function for profiling multiple threads, combining start-profiling and stop-profiling.

Package

hcl

Signature

do-profiling &key initialize processes profile-waiting ignore-in-foreign sleep function arguments func-and-args print stream

Arguments

initialize

A boolean.

processes

One of :current , :all , a mp:process or a list of mp:process objects.

profile-waiting

A boolean.

ignore-in-foreign

A boolean.

sleep

A non-negative number, or nil .

function

A function designator.

arguments

Arguments passed to function .

func-and-args

A function designator or a list ( function-designator . args ) .

print

A generalized boolean.

stream

An output stream.

Description

The function do-profiling is a convenience function for profiling multiple threads, combining start-profiling and stop-profiling.

The behavior of do-profiling with no arguments is the same as:

(progn
  (start-profiling :processes :all)
  (sleep 6)
  (stop-profiling))

The arguments initialize , processes , profile-waiting and ignore-in-foreign are passed to start-profiling. They have the same default values as for start-profiling, except processes which defaults to :all .

The arguments print and stream are passed to stop-profiling. They have the same default values as in stop-profiling.

sleep is the time to sleep in seconds. If sleep is nil or 0 do-profiling does not sleep. Also, if sleep is supplied and either function or func-and-args are passed, it does not sleep.

func-and-args , and function together with arguments , can both be used for calling a function you supply. func-and-args is either a list of the form ( function-designator . args ) , in which case function-designator is applied to the args , or it is a function designator which is called without arguments. function is applied to arguments .

The order of execution is first func-and-args (if this is non-nil), then function togeth with arguments if function is non-nil, and then sleep if sleep was passed explicitly or both function and func-and-args are nil .

Example

To profile whatever happens in the next 6 seconds:

(hcl:do-profiling)

To profile whatever happens in the next 10 minutes:

(hcl:do-profiling :sleep 600)

To run 4 processes in parallel with the same function and profile until they all die:

(defun check-all-processes-died (processes)
  (dolist (p processes t)
    (when (mp:process-alive-p p)
      (return nil))))
 
(let ((processes 
	(loop for x below 4
              collect
              (mp:process-run-function
               (format nil "my process ~a" x)
               () 'my-function))))
   (hcl:do-profiling
    :func-and-args
	(list 'mp:process-wait
              "Waiting for processes to finish"
              'check-all-process-died
              processes)))
See also

start-profiling
stop-profiling


LispWorks User Guide and Reference Manual - 22 Dec 2009

NextPrevUpTopContentsIndex