]> git.donarmstrong.com Git - lilypond.git/blob - lily/profile.cc
Run `make grand-replace'.
[lilypond.git] / lily / profile.cc
1 /*
2   profile.cc -- implement profiling utilities.
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2005--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "profile.hh"
10
11 void note_property_access (SCM *table, SCM sym);
12
13 SCM context_property_lookup_table;
14 SCM grob_property_lookup_table;
15 SCM prob_property_lookup_table;
16
17 LY_DEFINE (ly_property_lookup_stats, "ly:property-lookup-stats",
18            1, 0, 0, (SCM sym),
19            "Return hash table with a property access corresponding to"
20            " @var{sym}.  Choices are @code{prob}, @code{grob}, and"
21            " @code{context}.")
22 {
23   if (sym == ly_symbol2scm ("context"))
24     return context_property_lookup_table ? context_property_lookup_table
25       : scm_c_make_hash_table (1);
26   if (sym == ly_symbol2scm ("prob"))
27     return prob_property_lookup_table ? prob_property_lookup_table
28       : scm_c_make_hash_table (1);
29   if (sym == ly_symbol2scm ("grob"))
30     return grob_property_lookup_table ? grob_property_lookup_table
31       : scm_c_make_hash_table (1);
32   return scm_c_make_hash_table (1);
33 }
34
35
36 void
37 note_property_access (SCM *table, SCM sym)
38 {
39   /*
40     Statistics: which properties are looked up?
41   */
42   if (!*table)
43     *table = scm_permanent_object (scm_c_make_hash_table (259));
44
45   SCM hashhandle = scm_hashq_get_handle (*table, sym);
46   if (hashhandle == SCM_BOOL_F)
47     {
48       scm_hashq_set_x (*table, sym, scm_from_int (0));
49       hashhandle = scm_hashq_get_handle (*table, sym);
50     }
51
52   int count = scm_to_int (scm_cdr (hashhandle)) + 1;
53   scm_set_cdr_x (hashhandle, scm_from_int (count));
54 }