From: "Tommi Höynälänmaa" <tommi.hoynalanmaa@gmail.com>
To: guile-devel@gnu.org
Subject: Corrected cumulative time measuring support
Date: Tue, 26 Jan 2021 13:27:22 +0200 [thread overview]
Message-ID: <5f91eb67-438a-6091-9dcb-83992815f576@gmail.com> (raw)
[-- 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 --]
next reply other threads:[~2021-01-26 11:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-26 11:27 Tommi Höynälänmaa [this message]
2021-01-30 6:50 ` Corrected cumulative time measuring support Tommi Höynälänmaa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5f91eb67-438a-6091-9dcb-83992815f576@gmail.com \
--to=tommi.hoynalanmaa@gmail.com \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).