0
|
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
|
16
|
18 ;; along with XEmacs; see the file COPYING. If not, write to the
|
|
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 ;; Boston, MA 02111-1307, USA.
|
0
|
21
|
|
22 ;;; Synched up with: Not in FSF.
|
|
23
|
|
24 (defun pretty-print-profiling-info (&optional info)
|
|
25 "Print profiling info INFO to standard output in a pretty format.
|
|
26 If INFO is omitted, the current profiling info is retrieved using
|
|
27 `get-profiling-info'."
|
|
28 (if info (setq info (copy-alist info))
|
|
29 (setq info (get-profiling-info)))
|
|
30 (setq info (nreverse (sort info #'cdr-less-than-cdr)))
|
|
31 (princ "Function Count %\n")
|
|
32 (princ "---------------------------------------------------------------------\n")
|
|
33 (let ((sum 0.0)
|
|
34 (info2 info))
|
|
35 (while info2
|
|
36 (setq sum (+ sum (cdar info2)))
|
|
37 (setq info2 (cdr info2)))
|
|
38 (while info
|
|
39 (let ((f (caar info)))
|
|
40 (princ (format "%-50s%10d %6.3f\n" f (cdar info)
|
|
41 (* 100 (/ (cdar info) sum)))))
|
|
42 (setq info (cdr info)))))
|