comparison lisp/prim/profile.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 0293115a14e9
comparison
equal deleted inserted replaced
-1:000000000000 0:376386a54a3c
1 ;;; profile.el --- basic profiling commands for XEmacs
2
3 ;; Copyright (C) 1996 Ben Wing.
4
5 ;; This file is part of XEmacs.
6
7 ;; XEmacs is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
10 ;; any later version.
11
12 ;; XEmacs is distributed in the hope that it will be useful, but
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ;; General Public License for more details.
16
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with XEmacs; see the file COPYING. If not, write to the Free
19 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 ;;; Synched up with: Not in FSF.
22
23 (defun pretty-print-profiling-info (&optional info)
24 "Print profiling info INFO to standard output in a pretty format.
25 If INFO is omitted, the current profiling info is retrieved using
26 `get-profiling-info'."
27 (if info (setq info (copy-alist info))
28 (setq info (get-profiling-info)))
29 (setq info (nreverse (sort info #'cdr-less-than-cdr)))
30 (princ "Function Count %\n")
31 (princ "---------------------------------------------------------------------\n")
32 (let ((sum 0.0)
33 (info2 info))
34 (while info2
35 (setq sum (+ sum (cdar info2)))
36 (setq info2 (cdr info2)))
37 (while info
38 (let ((f (caar info)))
39 (princ (format "%-50s%10d %6.3f\n" f (cdar info)
40 (* 100 (/ (cdar info) sum)))))
41 (setq info (cdr info)))))