]> git.donarmstrong.com Git - lilypond.git/commitdiff
use a single function for asking profile info.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 5 Jan 2007 01:36:51 +0000 (02:36 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 5 Jan 2007 01:36:51 +0000 (02:36 +0100)
input/regression/profile-property-access.ly
lily/include/profile.hh
lily/include/program-option.hh
lily/prob.cc
lily/profile.cc
lily/program-option.cc

index c46bbf58dc3321133c507db63a1c0d97477f8394..641c24fe70c092138b4bc1f9749819ef972684cc 100644 (file)
@@ -7,27 +7,33 @@
 
 \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)
 
   
index fff7fa225cb6c2bacdb53a463d947ac867178c28..d8d4eff95782ce3e068b2fa02e1cedc6937cc0fa 100644 (file)
@@ -14,5 +14,7 @@
 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 */
index 55971a1fa16ba6a74e451ad6e5ed81cc0bd36783..bf5e253d59d41887938c9652ec948162abc9a9d6 100644 (file)
@@ -15,7 +15,6 @@ extern bool do_midi_debugging_global;
 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);
index a45e089a08fce1d1fa53a524b4a9726a04e387f8..9c3b40d712640c79aad814c8ed24c3b85c889c25 100644 (file)
@@ -10,6 +10,7 @@
 #include "main.hh"
 #include "item.hh"
 #include "input.hh"
+#include "profile.hh"
 
 #include "ly-smobs.icc"
 
@@ -140,6 +141,11 @@ Prob::print_smob (SCM smob, SCM port, scm_print_state*)
 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
    */
index 6531a3f3302f7877e0bbd3a331961bbafe842058..e1862c723647d2785e4a0b5de11259be6db83ff5 100644 (file)
@@ -12,22 +12,25 @@ void note_property_access (SCM *table, SCM sym);
 
 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)
index 8399cef9d5f042d2c269ba21b9e7ffc29780fabc..0c87be9dc8de10c108662ea8fd4bba7562ce1de5 100644 (file)
@@ -7,6 +7,7 @@
 */
 
 #include "program-option.hh"
+#include "profile.hh"
 
 #include <cstdio>
 #include <cstring>