unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Corrected cumulative time measuring support
@ 2021-01-26 11:27 Tommi Höynälänmaa
  2021-01-30  6:50 ` Tommi Höynälänmaa
  0 siblings, 1 reply; 2+ messages in thread
From: Tommi Höynälänmaa @ 2021-01-26 11:27 UTC (permalink / raw)
  To: guile-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 301 bytes --]

Hi

I made an enhanced version of Guile statprof that computes the 
cumulative time spent in procedures correctly (so that recursive 
invocations of the same procedure are counted only once). The patch is 
attached. Please inform me if you find any bugs.

      - Tommi Höynälänmaa



[-- Attachment #1.1.2: diff1.patch --]
[-- Type: text/x-patch, Size: 2838 bytes --]

31c31
< (define-module (statprof)
---
> (define-module (statprof-work)
358c358,359
<                   call-count cum-sample-count self-sample-count)
---
>                   call-count cum-sample-count corr-cum-sample-count
> 		  self-sample-count)
364a366,367
>   (corr-cum-sample-count call-data-corr-cum-sample-count
> 			 set-call-data-corr-cum-sample-count!)
389a393,396
> (define (inc-call-data-corr-cum-sample-count! cd)
>   (set-call-data-corr-cum-sample-count!
>    cd
>    (1+ (call-data-corr-cum-sample-count cd))))
427c434,435
<                                         0)))
---
>                                         0
> 					0)))
446c454,455
<           (let visit-stack ((pos pos))
---
>           (let visit-stack ((pos pos)
> 			    (visited-data '()))
450,451c459,463
<                    (inc-call-data-cum-sample-count! (addr->call-data ip))
<                    (visit-stack (1+ pos))))
---
> 		   (let ((cur-data (addr->call-data ip)))
> 		     (inc-call-data-cum-sample-count! cur-data)
> 		     (if (not (memv cur-data visited-data))
> 			 (inc-call-data-corr-cum-sample-count! cur-data))
> 		     (visit-stack (1+ pos) (cons cur-data visited-data)))))
505c517,518
<               %-time-in-proc cum-secs-in-proc self-secs-in-proc
---
>               %-time-in-proc cum-secs-in-proc corr-cum-secs-in-proc
> 	      self-secs-in-proc
511a525
>   (corr-cum-secs-in-proc statprof-stats-corr-cum-secs-in-proc)
536a551
>          (corr-cum-samples (call-data-corr-cum-sample-count call-data))
549a565
>                 (* corr-cum-samples secs-per-sample 1.0)
580c596
<         (format port "~6,2f ~9,2f ~9,2f"
---
>         (format port "~6,2f  ~9,2f  ~9,2f ~9,2f"
582a599
>                 (statprof-stats-corr-cum-secs-in-proc stats)
602,605c619,622
<             (format  port "~5a ~10a   ~7a  ~8a\n"
<                      "%  " "cumulative" "self" "")
<             (format  port "~5a  ~9a  ~8a  ~7a ~a\n"
<                      "time" "seconds" "seconds" "calls" "procedure"))
---
>             (format  port "~5a  ~10a ~10a  ~7a  ~8a\n"
>                      "%  " "cumulative" "corr. cum." "self" "")
>             (format  port "~5a  ~10a ~10a  ~8a  ~7a ~a\n"
>                      "time" "seconds" "seconds" "seconds" "calls" "procedure"))
607,610c624,627
<             (format  port "~5a ~10a   ~7a  ~8a\n"
<                      "%" "cumulative" "self" "")
<             (format  port "~5a  ~10a  ~7a  ~a\n"
<                      "time" "seconds" "seconds" "procedure")))
---
>             (format  port "~5a  ~10a ~10a  ~7a  ~8a\n"
>                      "%" "cumulative" "corr. cum." "self" "")
>             (format  port "~5a  ~10a ~10a  ~7a   ~a\n"
>                      "time" "seconds" "seconds" "seconds" "procedure")))

[-- Attachment #1.1.3: OpenPGP_0xBB861FDE40460F83.asc --]
[-- Type: application/pgp-keys, Size: 3199 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-30  6:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-26 11:27 Corrected cumulative time measuring support Tommi Höynälänmaa
2021-01-30  6:50 ` Tommi Höynälänmaa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).