]> git.donarmstrong.com Git - lilypond.git/commitdiff
Merge branch 'master' of ssh+git://hanwen@git.sv.gnu.org/srv/git/lilypond
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 5 Jan 2007 01:37:17 +0000 (02:37 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 5 Jan 2007 01:37:17 +0000 (02:37 +0100)
Documentation/topdocs/INSTALL.texi
THANKS
buildscripts/output-distance.py
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 d87936ce3d1cadeb0124b39f89b54f70b0271fa1..616eed601084caceba3f341beece0b8cc4338636 100644 (file)
@@ -187,6 +187,15 @@ For tracking memory usage as part of this test, you will need GUILE
 CVS; especially the following patch:
 @uref{http://lilypond.org/vc/gub.darcs/patches/guile-1.9-gcstats.patch}.
 
+For checking the coverage of the test suite, do the following
+
+@example
+  ./buildscripts/build-coverage.sh
+  @emph{# uncovered files, least covered first}
+  python ./buildscripts/coverage.py  --summary out-cov/*.cc
+  @emph{# consecutive uncovered lines, longest first} 
+  python ./buildscripts/coverage.py  --uncovered out-cov/*.cc
+@end example
 
 @section Building LilyPond
 
diff --git a/THANKS b/THANKS
index d74eb3abd76457f51c997ccf44a905a47a6980ce..f1f333c0abcb1eb714b5d9ed6605aaa3d46bae50 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -10,6 +10,7 @@ Jan Nieuwenhuizen - Core development
 Joe Neeman        - Core development
 Graham Percival   - Documentation Editor and Bug Meister
 Mats Bengtsson    - Support Guru 
+John Mandereau    - Translation Meister
 
 CONTRIBUTORS
 
index 5064ca6f3085cc14c9b096c9db3858688ee84596..4846af20b317c599fa34217daadfbe3186ea3ce5 100644 (file)
@@ -20,6 +20,38 @@ OUTPUT_EXPRESSION_PENALTY = 1
 ORPHAN_GROB_PENALTY = 1
 options = None
 
+################################################################
+# system interface.
+temp_dir = None
+class TempDirectory:
+    def __init__ (self):
+        import tempfile
+        self.dir = tempfile.mkdtemp ()
+        print 'dir is', self.dir
+    def __del__ (self):
+        print 'rm -rf %s' % self.dir 
+        os.system ('rm -rf %s' % self.dir )
+    def __call__ (self):
+        return self.dir
+
+
+def get_temp_dir  ():
+    global temp_dir
+    if not temp_dir:
+        temp_dir = TempDirectory ()
+    return temp_dir ()
+
+def read_pipe (c):
+    print 'pipe' , c
+    return os.popen (c).read ()
+
+def system (c):
+    print 'system' , c
+    s = os.system (c)
+    if s :
+        raise Exception ("failed")
+    return
+
 def shorten_string (s):
     threshold = 15 
     if len (s) > 2*threshold:
@@ -34,6 +66,39 @@ def max_distance (x1, x2):
         
     return dist
 
+
+def compare_png_images (old, new, dest_dir):
+    def png_dims (f):
+        m = re.search ('([0-9]+) x ([0-9]+)', read_pipe ('file %s' % f))
+        
+        return tuple (map (int, m.groups ()))
+
+    dest = os.path.join (dest_dir, new.replace ('.png', '.compare.jpeg'))
+    try:
+        dims1 = png_dims (old)
+        dims2 = png_dims (new)
+    except AttributeError:
+        ## hmmm. what to do?
+        system ('touch %(dest)s' % locals ())
+        return
+    
+    dims = (min (dims1[0], dims2[0]),
+            min (dims1[1], dims2[1]))
+
+    dir = get_temp_dir ()
+    system ('convert -depth 8 -crop %dx%d+0+0 %s %s/crop1.png' % (dims + (old, dir)))
+    system ('convert -depth 8 -crop %dx%d+0+0 %s %s/crop2.png' % (dims + (new, dir)))
+
+    system ('compare -depth 8 %(dir)s/crop1.png %(dir)s/crop2.png %(dir)s/diff.png' % locals ())
+
+    system ("convert  -depth 8 %(dir)s/diff.png -blur 0x3 -negate -channel alpha,blue -type TrueColorMatte -fx 'intensity'    %(dir)s/matte.png" % locals ())
+
+    system ("composite -quality 65 %(dir)s/matte.png %(new)s %(dest)s" % locals ())
+
+
+################################################################
+# interval/bbox arithmetic.
+
 empty_interval = (INFTY, -INFTY)
 empty_bbox = (empty_interval, empty_interval)
 
@@ -277,49 +342,11 @@ def read_signature_file (name):
 
 hash_to_original_name = {}
 
-
-def read_pipe (c):
-    print 'pipe' , c
-    return os.popen (c).read ()
-
-def system (c):
-    print 'system' , c
-    s = os.system (c)
-    if s :
-        raise Exception ("failed")
-    return
-
-def compare_png_images (old, new, dir):
-    def png_dims (f):
-        m = re.search ('([0-9]+) x ([0-9]+)', read_pipe ('file %s' % f))
-        
-        return tuple (map (int, m.groups ()))
-
-    dest = os.path.join (dir, new.replace ('.png', '.compare.jpeg'))
-    try:
-        dims1 = png_dims (old)
-        dims2 = png_dims (new)
-    except AttributeError:
-        ## hmmm. what to do?
-        system ('touch %(dest)s' % locals ())
-        return
-    
-    dims = (min (dims1[0], dims2[0]),
-            min (dims1[1], dims2[1]))
-
-    system ('convert -depth 8 -crop %dx%d+0+0 %s crop1.png' % (dims + (old,)))
-    system ('convert -depth 8 -crop %dx%d+0+0 %s crop2.png' % (dims + (new,)))
-
-    system ('compare -depth 8 crop1.png crop2.png diff.png')
-
-    system ("convert  -depth 8 diff.png -blur 0x3 -negate -channel alpha,blue -type TrueColorMatte -fx 'intensity'    matte.png")
-
-    system ("composite -quality 65 matte.png %(new)s %(dest)s" % locals ())
-
 class FileLink:
-    def __init__ (self):
+    def __init__ (self, f1, f2):
         self._distance = None
-
+        self.file_names = (f1, f2)
+        
     def text_record_string (self):
         return '%-30f %-20s\n' % (self.distance (),
                                   self.name ())
@@ -332,40 +359,72 @@ class FileLink:
 
         return self._distance
     
+        
     def name (self):
+        base = os.path.basename (self.file_names[1])
+        base = os.path.splitext (base)[0]
+        
+        base = hash_to_original_name.get (base, base)
+        base = os.path.splitext (base)[0]
+        return base
+
+    def extension (self):
         return '<undefined>'
+
+    def link_files_for_html (self, dest_dir):
+        for f in self.file_names:
+            link_file (f, os.path.join (dest_dir, f))
+
+    def get_distance_details (self):
+        return ''
+
+    def get_cell (oldnew):
+        return ''
     
-    def link_files_for_html (self, old_dir, new_dir, dest_dir):
-        pass
+    def get_file (self, oldnew):
+        return self.file_names[oldnew]
+    
+    def html_record_string (self, dest_dir):
+        self.link_files_for_html (dest_dir)
+        
+        dist = self.distance()
+        
+        details = self.get_distance_details ()
+        if details:
+            details_base = os.path.splitext (self.file_names[1])[0]
+            details_base += '.details.html'
+            fn = dest_dir + '/'  + details_base
+            open (fn, 'w').write (details)
+
+            details = '<br>(<a href="%(details_base)s">details</a>)' % locals ()
+
+        cell1 = self.get_cell (0)
+        cell2 = self.get_cell (1)
 
-    def write_html_system_details (self, dir1, dir2, dest_dir):
-        pass
+        name = self.name () + self.extension ()
+        file1 = self.get_file (0)
+        file2 = self.get_file (1)
         
-    def html_record_string (self,  old_dir, new_dir):
-        return ''
+        return '''<tr>
+<td>
+%(dist)f
+%(details)s
+</td>
+<td>%(cell1)s<br><font size=-2><a href="%(file1)s"><tt>%(name)s</tt></font></td>
+<td>%(cell2)s<br><font size=-2><a href="%(file2)s"><tt>%(name)s</tt></font></td>
+</tr>''' % locals ()
+
 
 class FileCompareLink (FileLink):
     def __init__ (self, f1, f2):
-        FileLink.__init__ (self)
-        self.files = (f1, f2)
-        self.contents = (self.get_content (self.files[0]),
-                         self.get_content (self.files[1]))
+        FileLink.__init__ (self, f1, f2)
+        self.contents = (self.get_content (self.file_names[0]),
+                         self.get_content (self.file_names[1]))
         
-    def link_files_for_html (self, old_dir, new_dir, dest_dir):
-        for f in self.files:
-            link_file (f, os.path.join (dest_dir, f))
 
     def extension (self):
         return '.ext'
-    
-    def name (self):
-        name = os.path.basename (self.files[0])
-        name = os.path.splitext (name)[0]
-        name = hash_to_original_name.get (name, name)
 
-        name = os.path.splitext (name)[0] + self.extension ()
-        return name
-    
     def calc_distance (self):
         ## todo: could use import MIDI to pinpoint
         ## what & where changed.
@@ -375,19 +434,6 @@ class FileCompareLink (FileLink):
         else:
             return 100.0;
         
-    def html_record_string (self, d1, d2):
-        (dist, f1, f2) = (self.distance(),) + self.files
-        b1 = os.path.basename (f1)
-        b2 = os.path.basename (f2)
-        
-        return '''<tr>
-<td>
-%(dist)f
-</td>
-<td><a href="%(f1)s"><tt>%(b1)s</tt></td>
-<td><a href="%(f2)s"><tt>%(b2)s</tt></td>
-</tr>''' % locals ()
-
     def get_content (self, f):
         print 'reading', f
         s = open (f).read ()
@@ -399,50 +445,61 @@ class TextFileCompareLink (FileCompareLink):
         import difflib
         diff = difflib.unified_diff (self.contents[0].strip().split ('\n'),
                                      self.contents[1].strip().split ('\n'),
-                                     fromfiledate = self.files[0],
-                                     tofiledate = self.files[1]
+                                     fromfiledate = self.file_names[0],
+                                     tofiledate = self.file_names[1]
                                      )
-
+        
         self.diff_lines =  [l for l in diff]
+        self.diff_lines = self.diff_lines[2:]
+        
         return float (len (self.diff_lines))
         
-    def link_files_for_html (self, old_dir, new_dir, dest_dir):
-        str = '\n'.join ([d.replace ('\n','') for d in self.diff_lines])
-        f = os.path.join (new_dir, self.name ()) + '.diff.txt'
-        f = os.path.join (dest_dir, f)
-        open_write_file (f).write (str)
+    def get_cell (self, oldnew):
+        str = ''
+        if oldnew == 1:
+            str = '\n'.join ([d.replace ('\n','') for d in self.diff_lines])
+        str = '<font size="-2"><pre>%s</pre></font>' % str
+        return str
 
     def extension (self):
         return '.txt'
     
-    def html_record_string (self, d1, d2):
-        (dist, f1, f2) = (self.distance(),) + self.files
-        b1 = os.path.basename (f1)
-        b2 = os.path.basename (f2)
-        
-        return '''<tr>
-<td>
-%f
-</td>
-<td><tt>%s</tt></td>
-<td><a href="%s.diff.txt"><tt>%s</tt></a></td>
-</tr>''' % (dist,
-            b1,
-            os.path.join (d2, self.name ()),
-            b2)
-
+class LogFileCompareLink (TextFileCompareLink):
+    def extension (self):
+        return '.log'
 
-class ProfileFileLink (TextFileCompareLink):
+class ProfileFileLink (FileCompareLink):
+    def __init__ (self, f1, f2):
+        FileCompareLink.__init__ (self, f1, f2)
+        self.results = [{}, {}]
+    
     def extension (self):
         return '.profile'
+
+    def get_cell (self, oldnew):
+        str = ''
+        for k in ('time', 'cells'):
+            if oldnew==0:
+                str += '%-8s: %d\n' %  (k, int (self.results[oldnew][k]))
+            else:
+                str += '%-8s: %8d (%5.3f)\n' % (k, int (self.results[oldnew][k]),
+                                         self.get_ratio (k))
+
+        return '<pre>%s</pre>' % str
+            
+    def get_ratio (self, key):
+        (v1,v2) = (self.results[0].get (key, -1),
+                   self.results[1].get (key, -1))
+
+        if v1 <= 0 or v2 <= 0:
+            return 0.0
+
+        return (v1 - v2) / float (v1+v2)
     
     def calc_distance (self):
-        TextFileCompareLink.calc_distance (self)
-        
-        r = [{},{}]
         for oldnew in (0,1):
             def note_info (m):
-                r[oldnew][m.group(1)] = float (m.group (2))
+                self.results[oldnew][m.group(1)] = float (m.group (2))
             
             re.sub ('([a-z]+): ([-0-9.]+)\n',
                     note_info, self.contents[oldnew])
@@ -453,17 +510,9 @@ class ProfileFileLink (TextFileCompareLink):
                   }
         
         for k in ('time', 'cells'):
-            (v1,v2) = (r[0].get (k , -1),
-                       r[1].get (k , -1))
-
-            if v1 <= 0 or v2 <= 0:
-                continue
-
-            ratio = abs (v2 - v1) / float (v1+v2)
-            dist += math.exp (ratio * factor[k]) - 1
+            dist += math.exp (self.get_ratio (k) * factor[k]) - 1
 
         dist = min (dist, 100)
-        
         return dist
 
 class MidiFileLink (FileCompareLink):
@@ -471,29 +520,25 @@ class MidiFileLink (FileCompareLink):
         s = FileCompareLink.get_content (self, f)
         s = re.sub ('LilyPond [0-9.]+', '', s)
         return s
-
+    
+    def get_cell (self, oldnew):
+        str = ''
+        if oldnew == 1 and self.distance () > 0:
+            str = 'changed' 
+        return str
+        
     def extension (self):
         return '.midi'
     
 
 class SignatureFileLink (FileLink):
-    def __init__ (self):
-        FileLink.__init__ (self)
-        self.base_names = ('','')
+    def __init__ (self, f1, f2 ):
+        FileLink.__init__ (self, f1, f2)
         self.system_links = {}
 
     def extension (self):
         return '.ly'
-    
-        
-    def name (self):
-        base = os.path.basename (self.base_names[1])
-        base = os.path.splitext (base)[0]
-        
-        base = hash_to_original_name.get (base, base)
-        base = os.path.splitext (base)[0] + self.extension ()
-        return base
-    
+
     def add_system_link (self, link, number):
         self.system_links[number] = link
 
@@ -546,7 +591,7 @@ class SignatureFileLink (FileLink):
         self.add_system_link (link, system_index[0])
 
     
-    def create_images (self, old_dir, new_dir, dest_dir):
+    def create_images (self, dest_dir):
 
         files_created = [[], []]
         for oldnew in (0, 1):
@@ -567,12 +612,13 @@ class SignatureFileLink (FileLink):
 
         return files_created
     
-    def link_files_for_html (self, old_dir, new_dir, dest_dir):
+    def link_files_for_html (self, dest_dir):
+        FileLink.link_files_for_html (self, dest_dir)
         to_compare = [[], []]
 
-        exts = ['.ly']
+        exts = []
         if options.create_images:
-            to_compare = self.create_images (old_dir, new_dir, dest_dir)
+            to_compare = self.create_images (dest_dir)
         else:
             exts += ['.png', '-page*png']
         
@@ -589,8 +635,8 @@ class SignatureFileLink (FileLink):
             for (old, new) in zip (to_compare[0], to_compare[1]):
                 compare_png_images (old, new, dest_dir)
 
-                
-    def html_record_string (self,  old_dir, new_dir):
+
+    def get_cell (self, oldnew):
         def img_cell (ly, img, name):
             if not name:
                 name = 'source'
@@ -598,13 +644,9 @@ class SignatureFileLink (FileLink):
                 name = '<tt>%s</tt>' % name
                 
             return '''
-<td align="center">
 <a href="%(img)s">
 <img src="%(img)s" style="border-style: none; max-width: 500px;">
 </a><br>
-<font size="-2">(<a href="%(ly)s">%(name)s</a>)
-</font>
-</td>
 ''' % locals ()
         def multi_img_cell (ly, imgs, name):
             if not name:
@@ -619,11 +661,7 @@ class SignatureFileLink (FileLink):
 
 
             return '''
-<td align="center">
 %(imgs_str)s
-<font size="-2">(<a href="%(ly)s">%(name)s</a>)
-</font>
-</td>
 ''' % locals ()
 
 
@@ -636,32 +674,17 @@ class SignatureFileLink (FileLink):
                 return multi_img_cell (base + '.ly', sorted (pages), name)
             else:
                 return img_cell (base + '.ly', base + '.png', name)
-            
-
-        html_2  = self.base_names[1] + '.html'
-        name = self.name ()
 
-        cell_1 = cell (self.base_names[0], name)
-        cell_2 = cell (self.base_names[1], name)
-        if options.compare_images:
-            cell_2 = cell_2.replace ('.png', '.compare.jpeg')
-        
-        html_entry = '''
-<tr>
-<td>
-%f<br>
-(<a href="%s">details</a>)
-</td>
 
-%s
-%s
-</tr>
-''' % (self.distance (), html_2, cell_1, cell_2)
 
-        return html_entry
+        str = cell (os.path.splitext (self.file_names[oldnew])[0], self.name ())  
+        if options.compare_images and oldnew == 1:
+            str = str.replace ('.png', '.compare.jpeg')
+            
+        return str
 
 
-    def html_system_details_string (self):
+    def get_distance_details (self):
         systems = self.system_links.items ()
         systems.sort ()
 
@@ -707,11 +730,6 @@ class SignatureFileLink (FileLink):
 ''' % locals ()
         return html
 
-    def write_html_system_details (self, dir1, dir2, dest_dir):
-        dest_file =  os.path.join (dest_dir, self.base_names[1] + '.html')
-
-        details = open_write_file (dest_file)
-        details.write (self.html_system_details_string ())
 
 ################################################################
 # Files/directories
@@ -732,20 +750,23 @@ def paired_files (dir1, dir2, pattern):
     Return (PAIRED, MISSING-FROM-2, MISSING-FROM-1)
 
     """
-    
-    files1 = dict ((os.path.split (f)[1], 1) for f in glob.glob (dir1 + '/' + pattern))
-    files2 = dict ((os.path.split (f)[1], 1) for f in glob.glob (dir2 + '/' + pattern))
 
+    files = []
+    for d in (dir1,dir2):
+        found = [os.path.split (f)[1] for f in glob.glob (d + '/' + pattern)]
+        found = dict ((f, 1) for f in found)
+        files.append (found)
+        
     pairs = []
     missing = []
-    for f in files1.keys ():
+    for f in files[0].keys ():
         try:
-            files2.pop (f)
+            files[1].pop (f)
             pairs.append (f)
         except KeyError:
             missing.append (f)
 
-    return (pairs, files2.keys (), missing)
+    return (pairs, files[1].keys (), missing)
     
 class ComparisonData:
     def __init__ (self):
@@ -778,7 +799,6 @@ class ComparisonData:
             for p in paired:
                 if (options.max_count
                     and len (self.file_links) > options.max_count):
-                    
                     continue
                 
                 f2 = dir2 +  '/' + p
@@ -813,7 +833,9 @@ class ComparisonData:
         try:
             file_link = self.file_links[name]
         except KeyError:
-            file_link = SignatureFileLink ()
+            generic_f1 = re.sub ('-[0-9]+.signature', '.ly', f1)
+            generic_f2 = re.sub ('-[0-9]+.signature', '.ly', f2)
+            file_link = SignatureFileLink (generic_f1, generic_f2)
             self.file_links[name] = file_link
 
         file_link.add_file_compare (f1, f2)
@@ -869,10 +891,7 @@ class ComparisonData:
         html = ''
         old_prefix = os.path.split (dir1)[1]
         for link in changed:
-            link.link_files_for_html (dir1, dir2, dest_dir) 
-            link.write_html_system_details (dir1, dir2, dest_dir)
-            
-            html += link.html_record_string (dir1, dir2)
+            html += link.html_record_string (dest_dir)
 
 
         short_dir1 = shorten_string (dir1)
@@ -928,6 +947,7 @@ def mkdir (x):
 def link_file (x, y):
     mkdir (os.path.split (y)[0])
     try:
+        print x, '->', y
         os.link (x, y)
     except OSError, z:
         print 'OSError', x, y, z
@@ -959,12 +979,12 @@ def test_compare_trees ():
     system ('cp 20expr{-*.signature,.ly,.png,.eps,.log,.profile} dir1')
     system ('cp 19{-*.signature,.ly,.png,.eps,.log,.profile} dir2/')
     system ('cp 19{-*.signature,.ly,.png,.eps,.log,.profile} dir1/')
-    system ('cp 19-1.signature 19-sub-1.signature')
-    system ('cp 19.ly 19-sub.ly')
-    system ('cp 19.profile 19-sub.profile')
-    system ('cp 19.log 19-sub.log')
-    system ('cp 19.png 19-sub.png')
-    system ('cp 19.eps 19-sub.eps')
+    system ('cp 19-1.signature 19.sub-1.signature')
+    system ('cp 19.ly 19.sub.ly')
+    system ('cp 19.profile 19.sub.profile')
+    system ('cp 19.log 19.sub.log')
+    system ('cp 19.png 19.sub.png')
+    system ('cp 19.eps 19.sub.eps')
 
     system ('cp 20multipage* dir1')
     system ('cp 20multipage* dir2')
@@ -972,8 +992,8 @@ def test_compare_trees ():
 
     
     system ('mkdir -p dir1/subdir/ dir2/subdir/')
-    system ('cp 19-sub{-*.signature,.ly,.png,.eps,.log,.profile} dir1/subdir/')
-    system ('cp 19-sub{-*.signature,.ly,.png,.eps,.log,.profile} dir2/subdir/')
+    system ('cp 19.sub{-*.signature,.ly,.png,.eps,.log,.profile} dir1/subdir/')
+    system ('cp 19.sub{-*.signature,.ly,.png,.eps,.log,.profile} dir2/subdir/')
     system ('cp 20grob{-*.signature,.ly,.png,.eps,.log,.profile} dir2/')
     system ('cp 20grob{-*.signature,.ly,.png,.eps,.log,.profile} dir1/')
 
@@ -982,9 +1002,9 @@ def test_compare_trees ():
     system ('cp 19.profile dir2/20.profile')
     system ('cp 19.png dir2/20.png')
     system ('cp 19multipage-page1.png dir2/20multipage-page1.png')
-    system ('cp 20-1.signature dir2/subdir/19-sub-1.signature')
-    system ('cp 20.png dir2/subdir/19-sub.png')
-    system ("sed 's/: /: 1/g'  20.profile > dir2/subdir/19-sub.profile")
+    system ('cp 20-1.signature dir2/subdir/19.sub-1.signature')
+    system ('cp 20.png dir2/subdir/19.sub.png')
+    system ("sed 's/: /: 1/g'  20.profile > dir2/subdir/19.sub.profile")
 
     ## radical diffs.
     system ('cp 19-1.signature dir2/20grob-1.signature')
@@ -1059,8 +1079,8 @@ def test_basic_compare ():
     }
     '''
 
-    open ('20multipage', 'w').write (multipage_str.replace ('c1', 'd1'))
-    open ('19multipage', 'w').write ('#(set-global-staff-size 19.5)\n' + multipage_str)
+    open ('20multipage.ly', 'w').write (multipage_str.replace ('c1', 'd1'))
+    open ('19multipage.ly', 'w').write ('#(set-global-staff-size 19.5)\n' + multipage_str)
     system ('lilypond -dseparate-log-files -ddump-signatures --png 19multipage 20multipage ')
  
     test_compare_signatures (names)
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>