guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about your profiling patch...


From: Rob Browning
Subject: Re: Question about your profiling patch...
Date: 05 Apr 2001 12:15:04 -0500
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Keisuke Nishida <address@hidden> writes:

> I see.  But I still don't know what is wrong with this.  Could you
> try with simpler examples?  What happens with the followings, for
> example:

I found at least one thing that's fairly odd, though I don't know if
it has any bearing on the problem we've been discussing.  I ran your
tests and the profiler's behavior varies depending on how I run guile.
If you'd like me to run some more tests, just let me know.

  $ guile -s test-profiler.scm
  Called Procedure                        Run  Real
  ------ ---------                        ---  ----

  0 007 address@hidden:~/sync/gmc/guile-profiled
  $ 


  $ guile -l test-profiler.scm
  Called Procedure                        Run  Real
  ------ ---------                        ---  ----
  3      bar                              0    0   
  1      foo-1                            1    0   
  1      foo-2                            0    0   
  1      foo-3                            0    0   
  guile> (quit) 

The code from test-profiler.scm:

  (use-modules (ice-9 session) (ice-9 format))

  (define (dump-profile-data)
    (let ((procs (let loop ((vals (map eval (apropos-internal "")))
                            (procs '()))
                   (if (null? vals)
                       procs
                       (let ((proc (car vals))
                             (data (object-property (car vals) 'profile-data)))
                         (if data
                             (loop (cdr vals) (acons proc data procs))
                             (loop (cdr vals) procs)))))))
      (display "Called Procedure                        Run  Real\n")
      (display "------ ---------                        ---  ----\n")
      (map (lambda (p)
             (let ((proc (car p)) (data (cdr p)))
               (format #t "~6a ~32a ~4a ~4a~%"
                       (vector-ref data 0)
                       (procedure-name proc)
                       (vector-ref data 1)
                       (vector-ref data 2))))
           (let ((real (lambda (p) (vector-ref (cdr p) 2)))
                 (count (lambda (p) (vector-ref (cdr p) 0))))
             (sort! procs (lambda (p1 p2)
                            (if (= (real p1) (real p2))
                                (> (count p1) (count p2))
                                (> (real p1) (real p2)))))))))


  (define (bar)
    #t)

  (define (foo-1)
    (let ((x #f))
      (begin (set! x (bar))
             (or x x))))

  (define (foo-2)
    (let ((x #f))
      (begin (bar)
             (or x x))))

  (define (foo-3)
    (let ((x #f))
      (set! x (bar))))

  (set! *profile-all* #t)
  (foo-1)
  (foo-2)
  (foo-3)
  (set! *profile-all* #f)

  (dump-profile-data)

-- 
Rob Browning <address@hidden> PGP=E80E0D04F521A094 532B97F5D64E3930



reply via email to

[Prev in Thread] Current Thread [Next in Thread]