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