[cairo-bugs] [Bug 24143] New: A suggestion on Performance optimization in cairo-pdf-operators.c.

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Thu Sep 24 21:35:46 PDT 2009


http://bugs.freedesktop.org/show_bug.cgi?id=24143

           Summary: A suggestion on Performance optimization in cairo-pdf-
                    operators.c.
           Product: cairo
           Version: 1.8.8
          Platform: x86 (IA32)
        OS/Version: Windows (All)
            Status: NEW
          Severity: enhancement
          Priority: medium
         Component: pdf backend
        AssignedTo: ajohnson at redneon.com
        ReportedBy: lliu at microstrategy.com
         QAContact: cairo-bugs at cairographics.org


I have done some profiling on cairo PDF backend using DevPartner. I found that
_count_word_up_to() consumes considerable amount of time. The related part of
profiling result is list as follows.

#       Count   %       Time
1                                       static int      
2                                       _count_word_up_to (const unsigned char
*s, int length)  
3       74,980  0.0     16,680.9        {       
4       74,980  0.0     15,453.6            int word = 0;       
5                               
6       259,305 0.1     47,794.9            while (length--) {  
7       259,305 5.2     3,597,598.4           if (! (isspace (*s) || *s ==
'<')) {      
8       184,325 0.1     36,245.0                s++;    
9       184,325 0.1     37,524.4                word++; 
10                                            } else {  
11      74,980  0.0     14,235.6                return word;    
12                                            } 
13                                          }   
14                                      
15                                          return word;        
16                                      }

Analysis:
Line 6 and Line 7 have been called for the same count (259305), but the time
taken by Line 7 is much longer than that of Line 6. The ratio can be calculated
as follows.
Time (Line 7) / Time (Line 6) = 3597598.4/47794.9 = 75.27


More information about the cairo-bugs mailing list