\version "2.10.8"
-\include "../../input/typography-demo.ly"
-%\book { \score { {c4 } } }
+%\include "../../input/typography-demo.ly"
+\book { \score { {c4 } } }
#(define (prop-stats>? x y) (> (cdr x) (cdr y)))
-#(define (display-stats what hash)
+#(define (display-stats what)
(let*
((count 50)
- (rnd 10))
- (ly:progress "\n~A properties, top ~a rounded to ~a\n~a"
+ (rnd 10)
+ (alist (hash-table->alist (ly:property-lookup-stats what)))
+ (total (apply + (map cdr alist)))
+ )
+
+ (set! alist (acons 'TOTAL total alist))
+
+ (ly:progress "\n\n~A properties, top ~a rounded to ~a\n\n~a"
what count rnd
(string-join
(map (lambda (x) (format "~30a: ~6@a" (car x) (* rnd (inexact->exact (round (/ (cdr x) rnd))))))
(take
- (sort (hash-table->alist hash) prop-stats>?) count))
+ (sort alist prop-stats>?) count))
"\n"))))
-#(display-stats "Context" (ly:context-property-lookup-stats))
-
-#(display-stats "Grob" (ly:grob-property-lookup-stats))
+#(display-stats 'prob)
+#(display-stats 'context)
+#(display-stats 'grob)
void note_property_access (SCM *table, SCM sym);
extern SCM context_property_lookup_table;
extern SCM grob_property_lookup_table;
+extern SCM prob_property_lookup_table;
+extern bool profile_property_accesses;
#endif /* PROFILE_HH */
extern int testing_level_global;
extern bool lily_1_8_relative;
extern bool lily_1_8_compatibility_used;
-extern bool profile_property_accesses;
SCM ly_get_option (SCM);
SCM ly_set_option (SCM, SCM);
#include "main.hh"
#include "item.hh"
#include "input.hh"
+#include "profile.hh"
#include "ly-smobs.icc"
SCM
Prob::internal_get_property (SCM sym) const
{
+#ifndef NDEBUG
+ if (profile_property_accesses)
+ note_property_access (&prob_property_lookup_table, sym);
+#endif
+
/*
TODO: type checking
*/
SCM context_property_lookup_table;
SCM grob_property_lookup_table;
+SCM prob_property_lookup_table;
-LY_DEFINE (ly_context_property_lookup_stats, "ly:context-property-lookup-stats",
- 0, 0, 0, (),
- "")
+LY_DEFINE (ly_property_lookup_stats, "ly:property-lookup-stats",
+ 1, 0, 0, (SCM sym),
+ "Return hash table with a property access corresponding to @var{sym}. "
+ "Choices are prob, grob and context.")
{
- return context_property_lookup_table ? context_property_lookup_table
- : scm_c_make_hash_table (1);
+ if (sym == ly_symbol2scm ("context"))
+ return context_property_lookup_table ? context_property_lookup_table
+ : scm_c_make_hash_table (1);
+ if (sym == ly_symbol2scm ("prob"))
+ return prob_property_lookup_table ? prob_property_lookup_table
+ : scm_c_make_hash_table (1);
+ if (sym == ly_symbol2scm ("grob"))
+ return grob_property_lookup_table ? grob_property_lookup_table
+ : scm_c_make_hash_table (1);
+ return scm_c_make_hash_table (1);
}
-LY_DEFINE (ly_property_lookup_stats, "ly:grob-property-lookup-stats",
- 0, 0, 0, (),
- "")
-{
- return grob_property_lookup_table ? grob_property_lookup_table
- : scm_c_make_hash_table (1);
-}
void
note_property_access (SCM *table, SCM sym)
*/
#include "program-option.hh"
+#include "profile.hh"
#include <cstdio>
#include <cstring>