annotate lisp/prim/profile.el @ 30:ec9a17fef872 r19-15b98

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