diff options
author | Richard M. Stallman <rms@gnu.org> | 1996-03-08 17:44:00 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1996-03-08 17:44:00 +0000 |
commit | 619393960473088d5339b47e0b2775ce6a0c46b4 (patch) | |
tree | 6f03e9303c9ae8706e57e26c945d38ebec9b7a81 /lisp/emacs-lisp | |
parent | 7f371164573ed5e547d9a9482356ac61f2475bb5 (diff) | |
download | emacs-619393960473088d5339b47e0b2775ce6a0c46b4.tar.gz emacs-619393960473088d5339b47e0b2775ce6a0c46b4.tar.bz2 emacs-619393960473088d5339b47e0b2775ce6a0c46b4.zip |
(profile-convert-byte-code): New function.
(profile-a-function): Use profile-convert-byte-code.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/profile.el | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/profile.el b/lisp/emacs-lisp/profile.el index b6333fc2740..272833dbd2c 100644 --- a/lisp/emacs-lisp/profile.el +++ b/lisp/emacs-lisp/profile.el @@ -218,9 +218,27 @@ With argument FLIST, use the list FLIST instead." (setcdr accum (- (cdr accum) profile-million))) ))) +(defun profile-convert-byte-code (function) + (let ((defn (symbol-function function))) + (if (byte-code-function-p defn) + ;; It is a compiled code object. + (let* ((contents (append defn nil)) + (body + (list (list 'byte-code (nth 1 contents) + (nth 2 contents) (nth 3 contents))))) + (if (nthcdr 5 contents) + (setq body (cons (list 'interactive (nth 5 contents)) body))) + (if (nth 4 contents) + ;; Use `documentation' here, to get the actual string, + ;; in case the compiled function has a reference + ;; to the .elc file. + (setq body (cons (documentation function) body))) + (fset function (cons 'lambda (cons (car contents) body))))))) + (defun profile-a-function (fun) "Profile the function FUN." (interactive "aFunction to profile: ") + (profile-convert-byte-code fun) (let ((def (symbol-function fun)) (funlen (length (symbol-name fun)))) (if (eq (car def) 'lambda) nil (error "To profile: %s must be a user-defined function" fun)) |