]> git.donarmstrong.com Git - lilypond.git/blob - input/regression/profile-property-access.ly
use a single function for asking profile info.
[lilypond.git] / input / regression / profile-property-access.ly
1 \header {
2   texidoc = "This file profiles property accesses; the log file shows the top properties examined."
3 }
4
5
6 #(ly:set-option 'profile-property-accesses #t)
7
8 \version "2.10.8"
9
10 %\include "../../input/typography-demo.ly"
11 \book { \score { {c4 } } }
12
13 #(define (prop-stats>?  x y) (> (cdr x) (cdr y)))
14
15 #(define (display-stats what)
16   (let*
17    ((count 50)
18     (rnd 10)
19     (alist (hash-table->alist (ly:property-lookup-stats what)))
20     (total (apply + (map cdr alist)))
21    )
22
23   (set! alist (acons 'TOTAL total alist))
24    
25   (ly:progress "\n\n~A properties, top ~a rounded to ~a\n\n~a"
26    what count rnd
27    (string-join
28     (map (lambda (x) (format "~30a: ~6@a" (car x) (* rnd (inexact->exact (round (/ (cdr x) rnd))))))
29      (take 
30     (sort alist prop-stats>?) count))
31     "\n"))))
32    
33
34                                  
35 #(display-stats 'prob)
36 #(display-stats 'context)
37 #(display-stats 'grob)
38
39