On Wed, Oct 11, 2017 at 12:27:09PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Oct 11, 2017 at 05:01:23PM +0200, Jiri Olsa escreveu:
> > hi,
> > I'm working on script profiling support and came up
> 
> Can you describe what you mean by "script profiling" and "script
> annotation"?

I have some prototype code that allows to get the
internal script stack to the sample and display
it later on in report:

Samples: 20K of event 'cycles:ppp', Event count (approx.): 10598322780
Overhead  Command  Script File                                                  
              Symbol                                                            
                                                       ▒
  42.29%  python3  /usr/lib64/python3.6/site-packages/hawkey/__init__.py        
              [.] union+0xe                                                     
                                                       ◆
  17.17%  python3  /usr/lib64/python3.6/site-packages/hawkey/__init__.py        
              [.] run+0x0                                                       
                                                       ▒
  16.80%  python3  /usr/lib/python3.6/site-packages/dnf/cli/output.py           
              [.] _skipped_packages+0x1e                                        
                                                       ▒
  13.64%  python3  N/A                                                          
              [.] 0x00007f9a96e655a2                                            
                                                       ▒
   1.48%  python3  N/A                                                          
              [.] 0x00005584196c4844                                            
                                                       ▒
   0.71%  python3  <frozen importlib._bootstrap>                                
              [.] _call_with_frames_removed+0x0                                 
                                                       ▒
   0.56%  python3  <frozen importlib._bootstrap_external>                       
              [.] _compile_bytecode+0x0                                         
                                                       ▒
   0.55%  python3  /usr/lib64/python3.6/site-packages/hawkey/__init__.py        
              [.] run+0x0                                                       
                                                       ▒
   0.23%  python3  /usr/lib64/python3.6/sre_parse.py                            
              [.] _parse+0x288                                                  
                                                       ▒
   0.20%  python3  /usr/lib64/python3.6/collections/__init__.py                 
              [.] namedtuple+0x174                                              
                                                       ▒
   0.16%  python3  N/A                                                          
              [.] 0x00007f9a89e9bc12                                            
                                                       ▒
   0.16%  python3  <frozen importlib._bootstrap_external>                       
              [.] _path_stat+0x0                                                
                                                       ▒


and annotate:

Percent│         # parse a simple pattern
       │       471:     subpattern = SubPattern(state)                          
                                                                                
                                                       ◆
       │
       │         # precompute constants into local variables
  2.00 │       474:     subpatternappend = subpattern.append                    
                                                                                
                                                       ▒
       │       475:     sourceget = source.get                                  
                                                                                
                                                       ▒
  2.00 │       476:     sourcematch = source.match                              
                                                                                
                                                       ▒
       │       477:     _len = len                                              
                                                                                
                                                       ▒
       │       478:     _ord = ord                                              
                                                                                
                                                       ▒
       │
       │       480:     while True:                                             
                                                                                
                                                       ▒
       │
  6.00 │       482:         this = source.next                                  
                                                                                
                                                       ▒
  4.00 │       483:         if this is None:                                    
                                                                                
                                                       ▒
       │       484:             break # end of pattern                          
                                                                                
                                                       ▒
  2.00 │       485:         if this in "|)":                                    
                                                                                
                                                       ▒
       │       486:             break # end of subpattern                       
                                                                                
                                                       ▒
 10.00 │       487:         sourceget()                                         
                                                                                
                                                       ▒
       │
  4.00 │       489:         if verbose:                                         
                                                                                
                                                       ▒
       │                 # skip whitespace and comments
  4.00 │       491:             if this in WHITESPACE:                          
                                                                                
                                                       ▒
       │       492:                 continue                                    
                                                                                
                                                       ▒
       │       493:             if this == "#":                                 
                                                                                
                                                       ▒
       │       494:                 while True:                                 
                                                                                
                                                       ▒
  2.00 │       495:                     this = sourceget()                      
                                                                                
                                                       ▒
  2.00 │ 64:   496:                     if this is None or this == "\n":        
                                                                                
                                                       ▒
       │       497:                         break                               
                                                                                
                                                       ▒
       │       498:                 continue                                    
                                                                                
                                                       ▒
       │
  6.00 │       500:         if this[0] == "\\":                                 
                                                                                
                                                       ▒
  2.00 │       501:             code = _escape(source, this, state)             
                                                                                
                                                       ▒


it so far for python.. I plan to post it next week

jirka

Reply via email to