Update .ly files.
[lilypond.git] / input / regression / profile-property-access.ly
blob4502719f68eed6e9fb3d6e5d7129962392d7c095
1 % -*- Scheme -*-
3 \header {
4 texidoc = "This file profiles property accesses; the log file shows the top properties examined."
8 #(ly:set-option 'profile-property-accesses #t)
10 \version "2.12.0"
12 \include "../../input/typography-demo.ly"
13 %\book { \score { {c4 } } }
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)))
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)))
31 (set! alist (acons 'TOTAL total alist))
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"))))
43 #(display-stats 'prob)
44 #(display-stats 'context)
45 #(display-stats 'grob)