]> git.donarmstrong.com Git - lilypond.git/blob - lily/profile.cc
Merge branch 'jneeman' of git+ssh://jneem@git.sv.gnu.org/srv/git/lilypond into jneeman
[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--2006 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
16 LY_DEFINE (ly_context_property_lookup_stats, "ly:context-property-lookup-stats",
17            0, 0, 0, (),
18            "")
19 {
20   return context_property_lookup_table ? context_property_lookup_table
21     : scm_c_make_hash_table (1);
22 }
23
24 LY_DEFINE (ly_property_lookup_stats, "ly:grob-property-lookup-stats",
25            0, 0, 0, (),
26            "")
27 {
28   return grob_property_lookup_table ? grob_property_lookup_table
29     : scm_c_make_hash_table (1);
30 }
31
32 void
33 note_property_access (SCM *table, SCM sym)
34 {
35   /*
36     Statistics: which properties are looked up?
37   */
38   if (!*table)
39     *table = scm_permanent_object (scm_c_make_hash_table (259));
40
41   SCM hashhandle = scm_hashq_get_handle (*table, sym);
42   if (hashhandle == SCM_BOOL_F)
43     {
44       scm_hashq_set_x (*table, sym, scm_from_int (0));
45       hashhandle = scm_hashq_get_handle (*table, sym);
46     }
47
48   int count = scm_to_int (scm_cdr (hashhandle)) + 1;
49   scm_set_cdr_x (hashhandle, scm_from_int (count));
50 }