ATLAS Offline Software
library_scraper.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
4 
5 
6 
7 """
8  --text - calls
9  pprof --text `which python` my.athena.profile > GProfile.txt
10  --callgrind
11  pprof --callgrind `which python` my.athena.profile > callgrind.out.GProfile
12 
13  --sqlite
14  --web
15 
16 TODO:
17  separate into different files for the classes
18  allow for some options (argparse)
19 
20  extend list of timers to be added to the list.
21 
22 """
23 import os
24 import shutil
25 import subprocess
26 
27 if __name__=="__main__":
28 
29  import argparse
30 
31  usage= "parses callgrind.out and creates web pages, and fills database with performance info"
32 
33  parser = argparse.ArgumentParser(description=usage)
34 
35  # dummy default
36  librarypathbase='./'
37  parser.add_argument('-p','--path', action='store', dest='librarypathbase', default=librarypathbase,
38  help='Location of the base path for the libraries')
39  # file names
40  dbfile='/afs/cern.ch/atlas/groups/Simulation/rtt/rttProfile.sqlite'
41  parser.add_argument('--dbfile', action='store', dest='dbfile',
42  default=dbfile,
43  help='location of the sqlite file ('+dbfile+')')
44  args = parser.parse_args()
45 
46  dd=[]
47  def runProcess(infile):
48  p = subprocess.Popen(['./libscrape.sh', infile], stdout=subprocess.PIPE,
49  stderr=subprocess.STDOUT)
50  while(True):
51  retcode = p.poll() #returns None while subprocess is running
52  line = p.stdout.readline()
53  yield line
54  if(retcode is not None):
55  break
56  def chomp(s):
57  return s[:-1] if s.endswith('\n') else s
58 
59  import glob
60  for infile in glob.glob( os.path.join(args.librarypathbase, 'lib*.so') ):
61  import re
62  result = re.search('lib\/lib(.*).so', infile)
63  packagename = result.group(1)
64  for line in runProcess(infile):
65  line = chomp(line)
66  if not line.startswith('GaudiDll'):
67  print line
68  dd+= [(line,packagename)]
69  print dd
70 
71 
72 
73 
78 
library_scraper.runProcess
def runProcess(infile)
Definition: library_scraper.py:47
library_scraper.chomp
def chomp(s)
Definition: library_scraper.py:56
while
while((inf=(TStreamerInfo *) nextinfo()) !=0)
Definition: liststreamerinfos.cxx:13
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567