MIDI: fix regtest failure
[lilypond/patrick.git] / input / regression / profile-property-access.ly
blob9073e7c29314d5967fb8760c94949de30d249f93
1 % -*- Scheme -*-
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."
9 #(ly:set-option 'profile-property-accesses #t)
11 \version "2.12.0"
13 \include "typography-demo.ly"
14 %\book { \score { {c4 } } }
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)))
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)))
32 (set! alist (acons 'TOTAL total alist))
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 "~30a: ~6@a" (car x) (cdr x)))
38 (ly:truncate-list!
39 (sort alist prop-stats>?) count))
40 "\n"))))
44 #(display-stats 'prob)
45 #(display-stats 'context)
46 #(display-stats 'grob)