Дать подробное описание объекту
(defun fact (n)
(if (zerop n)
1
(* n (fact (- n 1)))))
(describe #'fact)
#<FUNCTION FACT (N) (DECLARE (SYSTEM::IN-DEFUN FACT)) (BLOCK FACT (IF # 1 #))>
is an interpreted function.
Argument list: (N)
Проследить вызовы функции
(defun fact (n)
(if (zerop n)
1
(* n (fact (- n 1)))))
(trace fact)
(fact 3)
(untrace fact)
0: (FACT 3)
1: (FACT 2)
2: (FACT 1)
3: (FACT 0)
3: FACT returned 1
2: FACT returned 1
1: FACT returned 2
0: FACT returned 6
6
Итеративно инспектировать объект
(inspect #'foo)
Вызвать дебаггер в определённом месте
(break "You have entered the debugger with arguments: ~s" '(1 2 3))
You have entered the debugger with arguments: (1 2 3)
[Condition of type SIMPLE-CONDITION]
Restarts:
0: [CONTINUE] Return from BREAK loop
1: [ABORT-REQUEST] Abort handling SLIME request.
2: [ABORT] Return to SLIME top-level.
3: [ABORT] ABORT
Замерить время выполнения участка кода
(defun add-n-squares (n)
(do ((i 0 (+ i 1))
(sum 0 (+ sum (* i i))))
((> i n) sum)))
(time (add-n-squares 10000))
Evaluation took:
0.001 seconds of real time
0.004000 seconds of total run time (0.004000 user, 0.000000 system)
400.00% CPU
3,090,464 processor cycles
212,792 bytes consed
333383335000
Посмотреть состояние памяти лиспа
(room)
Bytes permanently allocated: 90624
Bytes currently in use: 3258228
Bytes available until next GC: 180536
3258228
180536
Источники:
- 1-2, 4-6 - vmathew.in