]> git.donarmstrong.com Git - lilypond.git/blob - input/regression/profile-property-access.ly
Issue 5167/6: Changes: show \markup xxx = ... \etc assignments
[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 Note: lilypond must be compiled with --disable-optimising for this file to work."
6 }
7
8
9 #(ly:set-option 'profile-property-accesses #t)
10
11 \version "2.16.0"
12
13 \include "typography-demo.ly"
14 %\book { \score { {c4 } } }
15
16 #(define (prop-stats>?  x y)
17   (cond
18    ((> (cdr x) (cdr y)) #t)
19    ((= (cdr x) (cdr y))
20     (symbol<? (car x) (car y)))
21    (else #f)))
22
23 #(define (display-stats what)
24   (let*
25    ((count 50)
26     (rnd 10)
27     (round-to (lambda (x) (* rnd (inexact->exact (round (/ x rnd))))))
28     (alist (map (lambda (entry) (cons (car entry) (round-to (cdr entry)))) (hash-table->alist (ly:property-lookup-stats what))))
29     (total (apply + (map cdr alist)))
30    )
31
32   (set! alist (acons 'TOTAL total alist))
33    
34   (ly:progress "\n\n~A properties, top ~a rounded to ~a\n\n~a"
35    what count rnd
36    (string-join
37     (map (lambda (x) (format #f "~30a: ~6@a" (car x) (cdr x)))
38      (ly:truncate-list! 
39     (sort alist prop-stats>?) count))
40     "\n"))))
41    
42
43                                  
44 #(display-stats 'prob)
45 #(display-stats 'context)
46 #(display-stats 'grob)
47
48