~ubuntu-branches/ubuntu/maverick/uim/maverick

« back to all changes in this revision

Viewing changes to emacs/uim-debug.el

  • Committer: Bazaar Package Importer
  • Author(s): Masahito Omote
  • Date: 2006-11-23 15:10:53 UTC
  • mfrom: (3.1.8 edgy)
  • Revision ID: james.westby@ubuntu.com-20061123151053-q42sk1lvks41xpfx
Tags: 1:1.2.1-9
uim-gtk2.0.postinst: Don't call update-gtk-immodules on purge.
(closes: Bug#398530)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;; 
 
2
;;  Copyright (c) 2005-2006 uim Project http://uim.freedesktop.org/
 
3
;;
 
4
;;  All rights reserved.
 
5
;;
 
6
;;  Redistribution and use in source and binary forms, with or
 
7
;;  without modification, are permitted provided that the
 
8
;;  following conditions are met:
 
9
;;
 
10
;;  1. Redistributions of source code must retain the above
 
11
;;     copyright notice, this list of conditions and the
 
12
;;     following disclaimer.
 
13
;;  2. Redistributions in binary form must reproduce the above
 
14
;;     copyright notice, this list of conditions and the
 
15
;;     following disclaimer in the documentation and/or other
 
16
;;     materials provided with the distribution.
 
17
;;  3. Neither the name of authors nor the names of its
 
18
;;     contributors may be used to endorse or promote products
 
19
;;     derived from this software without specific prior written
 
20
;;     permission.
 
21
;;
 
22
;;  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 
23
;;  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 
24
;;  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 
25
;;  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
26
;;  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 
27
;;  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
28
;;  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 
29
;;  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 
30
;;  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
31
;;  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
32
;;  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 
33
;;  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
34
;;  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
35
;;
 
36
 
 
37
(defvar uim-debug-enable nil) 
 
38
(defvar uim-debug-buffer nil)
 
39
(defconst uim-debug-buffer-name "uim-debug")
 
40
 
 
41
(defvar uim-timestamp-list nil)
 
42
 
 
43
(defun uim-debug (msg)
 
44
  (if uim-debug-enable
 
45
      (progn
 
46
        (if (not uim-debug-buffer)
 
47
            (setq uim-debug-buffer (get-buffer-create uim-debug-buffer-name)))
 
48
        (save-current-buffer
 
49
          (set-buffer uim-debug-buffer)
 
50
          (goto-char 0)
 
51
          (insert msg)
 
52
          (insert "\n")))))
 
53
 
 
54
(defun uim-timestamp (name)
 
55
  (setq uim-timestamp-list (append uim-timestamp-list
 
56
                                   (list (list (current-time) name)))))
 
57
 
 
58
(defun uim-reset-timestamp ()
 
59
  (setq uim-timestamp-list nil))
 
60
 
 
61
(defun uim-show-timestamp ()
 
62
  (let (sec1 sec2 microsec current (start 0))
 
63
    (while uim-timestamp-list
 
64
      (setq sec1 (nth 0 (caar uim-timestamp-list)))
 
65
      (setq sec2 (nth 1 (caar uim-timestamp-list)))
 
66
      (setq microsec (nth 2 (caar uim-timestamp-list)))
 
67
      (setq current (+ (* (+ (lsh sec1 16) sec2) 1000) (/ microsec 1000)))
 
68
 
 
69
      (if (= start 0)
 
70
          (setq start current))
 
71
 
 
72
      (uim-debug (format "%5d :%s (%d)"
 
73
                         (- current start)
 
74
                         (car (cdar uim-timestamp-list))
 
75
                         (memory-limit)
 
76
                         ))
 
77
 
 
78
      (setq uim-timestamp-list (cdr uim-timestamp-list)))))
 
79
 
 
80
(provide 'uim-debug)
 
81