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

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Sun Sep 27 01:35:01 PDT 2009


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


Lance <lliu at microstrategy.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lliu at microstrategy.com




--- Comment #1 from Lance <lliu at microstrategy.com>  2009-09-27 01:34:59 PST ---
(In reply to comment #0)
> 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
> From the source code, I think such a big ratio is caused by inefficent
> isspace(). I think the functionality of isspace() should be simple based on the
> method name. So I suggest replacing isspace() with an efficent implementation,
> for example, using a switch-case or a look-up table.

In addition to isspace() method, isdigit() has a similar problem. In my
profiling result. isspace() and isdigit() took 11.0% and 7.5% respectively. So
it would be nice to have light implementations for these two methods.

Thanks,
Lance


-- 
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the cairo-bugs mailing list